From 8a45637f324d00b9cd7f777e3444d9d1662e4c65 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 29 Dec 2021 13:14:42 +0300 Subject: [PATCH] [DE] Lock buttons on forms, references. view tabs --- .../main/app/controller/FormsTab.js | 21 ++---- .../main/app/controller/Links.js | 39 +++++------ .../main/app/controller/PageLayout.js | 67 ++++++++++--------- .../main/app/controller/ViewTab.js | 6 +- apps/documenteditor/main/app/view/FormsTab.js | 33 +++++---- apps/documenteditor/main/app/view/Links.js | 28 +++++--- apps/documenteditor/main/app/view/Toolbar.js | 18 +++-- apps/documenteditor/main/app/view/ViewTab.js | 20 +++--- 8 files changed, 124 insertions(+), 108 deletions(-) diff --git a/apps/documenteditor/main/app/controller/FormsTab.js b/apps/documenteditor/main/app/controller/FormsTab.js index b353a076a..0ceefda70 100644 --- a/apps/documenteditor/main/app/controller/FormsTab.js +++ b/apps/documenteditor/main/app/controller/FormsTab.js @@ -57,9 +57,7 @@ define([ initialize: function () { }, onLaunch: function () { - this._state = { - prcontrolsdisable:undefined - }; + this._state = {}; }, setApi: function (api) { @@ -145,17 +143,12 @@ define([ control_plain = (in_control&&control_props) ? (control_props.get_ContentControlType()==Asc.c_oAscSdtLevelType.Inline) : false; (lock_type===undefined) && (lock_type = Asc.c_oAscSdtLockType.Unlocked); var content_locked = lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.ContentLocked; - var need_disable = (paragraph_locked || header_locked || control_plain || content_locked); - if (this._state.prcontrolsdisable !== need_disable) { - this.view.btnTextField.setDisabled(need_disable); - this.view.btnComboBox.setDisabled(need_disable); - this.view.btnDropDown.setDisabled(need_disable); - this.view.btnCheckBox.setDisabled(need_disable); - this.view.btnRadioBox.setDisabled(need_disable); - this.view.btnImageField.setDisabled(need_disable); - this.view.btnTextField.setDisabled(need_disable); - this._state.prcontrolsdisable = need_disable; - } + 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}); }, onChangeSpecialFormsGlobalSettings: function() { diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index 4a76a9bbf..86ded0add 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -87,7 +87,6 @@ define([ }, onLaunch: function () { this._state = { - prcontrolsdisable:undefined, in_object: undefined }; Common.Gateway.on('setactionlink', function (url) { @@ -164,7 +163,6 @@ define([ object_type = type; } } - this._state.prcontrolsdisable = paragraph_locked || header_locked; this._state.in_object = object_type; var control_props = this.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null, @@ -176,28 +174,31 @@ 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.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.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.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]}); - var need_disable = paragraph_locked || in_equation || in_image || in_header || control_plain || rich_edit_lock || plain_edit_lock; - this.view.btnsNotes.setDisabled(need_disable); + this.dlgCrossRefDialog && this.dlgCrossRefDialog.isVisible() && this.dlgCrossRefDialog.setLocked(this.view.btnCrossRef.isDisabled()); + }, - need_disable = paragraph_locked || header_locked || in_header || control_plain; - this.view.btnBookmarks.setDisabled(need_disable); - - need_disable = in_header || rich_edit_lock || plain_edit_lock || rich_del_lock || plain_del_lock; - this.view.btnsContents.setDisabled(need_disable); - this.view.btnTableFigures.setDisabled(need_disable); - this.view.btnTableFiguresUpdate.setDisabled(need_disable || paragraph_locked || !this.api.asc_CanUpdateTablesOfFigures()); - - need_disable = in_header; - this.view.btnCaption.setDisabled(need_disable); - - need_disable = paragraph_locked || header_locked || control_plain || rich_edit_lock || plain_edit_lock || content_locked; - this.view.btnCrossRef.setDisabled(need_disable); - this.dlgCrossRefDialog && this.dlgCrossRefDialog.isVisible() && this.dlgCrossRefDialog.setLocked(need_disable); + lockToolbar: function (causes, lock, opts) { + Common.Utils.lockControls(causes, lock, opts, this.view.getButtons()); }, onApiCanAddHyperlink: function(value) { - this.toolbar.editMode && this.view.btnsHyperlink.setDisabled(!value || this._state.prcontrolsdisable); + this.toolbar.editMode && this.lockToolbar(DE.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 222538d4a..2b51efd8a 100644 --- a/apps/documenteditor/main/app/controller/PageLayout.js +++ b/apps/documenteditor/main/app/controller/PageLayout.js @@ -124,17 +124,23 @@ define([ if (!this.editMode) return; var me = this; - var disable = [], type; + var disable = {}, type, + islocked = false, + shapeProps, + canGroupUngroup = false, + wrapping, + content_locked = false, + no_object = true; for (var i in objects) { type = objects[i].get_ObjectType(); if ( type === Asc.c_oAscTypeSelectElement.Image ) { var props = objects[i].get_ObjectValue(), - shapeProps = props.get_ShapeProperties(); - var islocked = props.get_Locked(); - var notflow = !props.get_CanBeFlow(); - - var wrapping = props.get_WrappingStyle(); + notflow = !props.get_CanBeFlow(); + shapeProps = props.get_ShapeProperties(); + islocked = props.get_Locked(); + wrapping = props.get_WrappingStyle(); + no_object = false; me.onApiWrappingStyleChanged(notflow ? -1 : wrapping); _.each(me.toolbar.btnImgWrapping.menu.items, function(item) { @@ -143,47 +149,42 @@ define([ me.toolbar.btnImgWrapping.menu.items[8].setDisabled(!me.api.CanChangeWrapPolygon()); var control_props = me.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null, - lock_type = (control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked, - content_locked = lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.ContentLocked; + lock_type = (control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked; - disable.align = islocked || wrapping == Asc.c_oAscWrapStyle2.Inline || content_locked; - disable.group = islocked || wrapping == Asc.c_oAscWrapStyle2.Inline || content_locked; - disable.arrange = (wrapping == Asc.c_oAscWrapStyle2.Inline) && !props.get_FromGroup() || shapeProps && shapeProps.asc_getFromSmartArtInternal() || content_locked; - disable.wrapping = islocked || props.get_FromGroup() || (notflow && !me.api.CanChangeWrapPolygon()) || content_locked || + content_locked = lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.ContentLocked; + disable.arrange = (wrapping == Asc.c_oAscWrapStyle2.Inline) && !props.get_FromGroup(); + disable.wrapping = props.get_FromGroup() || (notflow && !me.api.CanChangeWrapPolygon()) || (!!control_props && control_props.get_SpecificType()==Asc.c_oAscContentControlSpecificType.Picture && !control_props.get_FormPr()); - - if ( !disable.group ) { - if (me.api.CanGroup() || me.api.CanUnGroup()) { - var mnuGroup = me.toolbar.btnImgGroup.menu.items[0], - mnuUnGroup = me.toolbar.btnImgGroup.menu.items[1]; - - mnuGroup.setDisabled(!me.api.CanGroup()); - mnuUnGroup.setDisabled(!me.api.CanUnGroup()); - } else - disable.group = true; + disable.group = islocked || wrapping == Asc.c_oAscWrapStyle2.Inline || content_locked; + canGroupUngroup = me.api.CanGroup() || me.api.CanUnGroup(); + if (!disable.group && canGroupUngroup) { + me.toolbar.btnImgGroup.menu.items[0].setDisabled(!me.api.CanGroup()); + me.toolbar.btnImgGroup.menu.items[1].setDisabled(!me.api.CanUnGroup()); } _imgOriginalProps = props; break; } } - - me.toolbar.btnImgAlign.setDisabled(disable.align !== false); - me.toolbar.btnImgGroup.setDisabled(disable.group !== false); - me.toolbar.btnImgForward.setDisabled(disable.arrange !== false); - me.toolbar.btnImgBackward.setDisabled(disable.arrange !== false); - me.toolbar.btnImgWrapping.setDisabled(disable.wrapping !== false); + 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]}); }, onApiCoAuthoringDisconnect: function() { var me = this; me.editMode = false; - me.toolbar.btnImgAlign.setDisabled(true); - me.toolbar.btnImgGroup.setDisabled(true); - me.toolbar.btnImgForward.setDisabled(true); - me.toolbar.btnImgBackward.setDisabled(true); - me.toolbar.btnImgWrapping.setDisabled(true); + // me.toolbar.btnImgAlign.setDisabled(true); + // me.toolbar.btnImgGroup.setDisabled(true); + // me.toolbar.btnImgForward.setDisabled(true); + // me.toolbar.btnImgBackward.setDisabled(true); + // me.toolbar.btnImgWrapping.setDisabled(true); }, onBeforeShapeAlign: function() { diff --git a/apps/documenteditor/main/app/controller/ViewTab.js b/apps/documenteditor/main/app/controller/ViewTab.js index 4f8128f23..8a9983b0b 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); - me.view.btnDarkDocument.setDisabled(!Common.UI.Themes.isDarkTheme()); + Common.Utils.lockControls(DE.enumLock.inLightTheme, !Common.UI.Themes.isDarkTheme(), {array: [me.view.btnDarkDocument]}); }, me)); setTimeout(function () { me.onContentThemeChangedToDark(Common.UI.Themes.isContentThemeDark()); - me.view.btnDarkDocument.setDisabled(!Common.UI.Themes.isDarkTheme()); + Common.Utils.lockControls(DE.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); - this.view.btnDarkDocument.setDisabled(!Common.UI.Themes.isDarkTheme()); + Common.Utils.lockControls(DE.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 2183d893b..808a60a04 100644 --- a/apps/documenteditor/main/app/view/FormsTab.js +++ b/apps/documenteditor/main/app/view/FormsTab.js @@ -142,6 +142,7 @@ define([ this.paragraphControls = []; var me = this; + var _set = DE.enumLock; if (this.appConfig.isRestrictedEdit && this.appConfig.canFillForms) { this.btnClear = new Common.UI.Button({ @@ -153,8 +154,8 @@ define([ this.btnTextField = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-text-field', + lock: [_set.paragraphLock, _set.headerLock, _set.controlPlain, _set.contentLock, _set.lostConnect, _set.disableOnStart], caption: this.capBtnText, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -164,8 +165,8 @@ define([ this.btnComboBox = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-combo-box', + lock: [_set.paragraphLock, _set.headerLock, _set.controlPlain, _set.contentLock, _set.lostConnect, _set.disableOnStart], caption: this.capBtnComboBox, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -175,8 +176,8 @@ define([ this.btnDropDown = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-dropdown', + lock: [_set.paragraphLock, _set.headerLock, _set.controlPlain, _set.contentLock, _set.lostConnect, _set.disableOnStart], caption: this.capBtnDropDown, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -186,8 +187,8 @@ define([ this.btnCheckBox = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-checkbox', + lock: [_set.paragraphLock, _set.headerLock, _set.controlPlain, _set.contentLock, _set.lostConnect, _set.disableOnStart], caption: this.capBtnCheckBox, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -197,8 +198,8 @@ define([ this.btnRadioBox = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-radio-button', + lock: [_set.paragraphLock, _set.headerLock, _set.controlPlain, _set.contentLock, _set.lostConnect, _set.disableOnStart], caption: this.capBtnRadioBox, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -208,8 +209,8 @@ define([ this.btnImageField = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-insertimage', + lock: [_set.paragraphLock, _set.headerLock, _set.controlPlain, _set.contentLock, _set.lostConnect, _set.disableOnStart], caption: this.capBtnImage, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -219,9 +220,9 @@ define([ this.btnViewForm = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-sheet-view', + lock: [_set.lostConnect, _set.disableOnStart], caption: this.capBtnView, enableToggle: true, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -231,8 +232,8 @@ define([ this.btnClearFields = new Common.UI.Button({ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-clearstyle', + lock: [_set.lostConnect, _set.disableOnStart], caption : this.textClearFields, - disabled: true, dataHint : '1', dataHintDirection: 'left', dataHintOffset: 'small' @@ -242,9 +243,9 @@ define([ this.btnHighlight = new Common.UI.ButtonColored({ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-highlight', + lock: [_set.lostConnect, _set.disableOnStart], caption : this.textHighlight, menu : true, - disabled: true, additionalItems: [ this.mnuNoFormsColor = new Common.UI.MenuItem({ id: 'id-toolbar-menu-no-highlight-form', caption: this.textNoHighlight, @@ -268,8 +269,9 @@ define([ this.btnPrevForm = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon previous-field', + lock: [_set.lostConnect, _set.disableOnStart], caption: this.capBtnPrev, - disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode + // disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -279,8 +281,9 @@ define([ this.btnNextForm = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon next-field', + lock: [_set.lostConnect, _set.disableOnStart], caption: this.capBtnNext, - disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode, + // disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -291,8 +294,9 @@ define([ this.btnSubmit = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon submit-form', + lock: [_set.lostConnect, _set.disableOnStart], caption: this.capBtnSubmit, - disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode, + // disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -302,16 +306,17 @@ define([ if (this.appConfig.canDownloadForms) { this.btnSaveForm = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', + lock: [_set.lostConnect, _set.disableOnStart], iconCls: 'toolbar__icon save-form', caption: this.capBtnSaveForm, - disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode, + // disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' }); this.paragraphControls.push(this.btnSaveForm); } - + Common.Utils.lockControls(DE.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 adec4df29..3be0f84ae 100644 --- a/apps/documenteditor/main/app/view/Links.js +++ b/apps/documenteditor/main/app/view/Links.js @@ -157,23 +157,29 @@ define([ this.btnsPrevEndNote = []; this.btnsNextEndNote = []; this.paragraphControls = []; - + var _set = DE.enumLock; var me = this, $host = me.toolbar.$el; - this.btnsContents = Common.Utils.injectButtons($host.find('.btn-slot.btn-contents'), '', 'toolbar__icon btn-contents', me.capBtnInsContents, undefined, true, true, undefined, '1', 'bottom', 'small'); - this.btnsNotes = Common.Utils.injectButtons($host.find('.btn-slot.slot-notes'), '', 'toolbar__icon btn-notes', me.capBtnInsFootnote, undefined, true, true, undefined, '1', 'bottom', 'small'); - this.btnsHyperlink = Common.Utils.injectButtons($host.find('.btn-slot.slot-inshyperlink'), '', 'toolbar__icon btn-inserthyperlink', me.capBtnInsLink, undefined, undefined, undefined, undefined, '1', 'bottom', 'small'); + this.btnsContents = Common.Utils.injectButtons($host.find('.btn-slot.btn-contents'), '', 'toolbar__icon btn-contents', me.capBtnInsContents, + [_set.inHeader, _set.richEditLock, _set.plainEditLock, _set.richDelLock, _set.plainDelLock, _set.lostConnect, _set.disableOnStart], + true, true, undefined, '1', 'bottom', 'small'); + this.btnsNotes = Common.Utils.injectButtons($host.find('.btn-slot.slot-notes'), '', 'toolbar__icon btn-notes', me.capBtnInsFootnote, + [_set.paragraphLock, _set.inEquation, _set.inImage, _set.inHeader, _set.controlPlain, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart], + true, true, undefined, '1', 'bottom', 'small'); + this.btnsHyperlink = Common.Utils.injectButtons($host.find('.btn-slot.slot-inshyperlink'), '', 'toolbar__icon btn-inserthyperlink', me.capBtnInsLink, + [_set.paragraphLock, _set.headerLock, _set.hyperlinkLock, _set.lostConnect, _set.disableOnStart], + undefined, undefined, undefined, '1', 'bottom', 'small'); Array.prototype.push.apply(this.paragraphControls, this.btnsContents.concat(this.btnsNotes, this.btnsHyperlink)); this.btnContentsUpdate = new Common.UI.Button({ parentEl: $host.find('#slot-btn-contents-update'), cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-update', + lock: [_set.lostConnect, _set.disableOnStart], caption: this.capBtnContentsUpdate, split: true, menu: true, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -184,8 +190,8 @@ define([ parentEl: $host.find('#slot-btn-bookmarks'), cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-bookmarks', + lock: [_set.paragraphLock, _set.inHeader, _set.headerLock, _set.controlPlain, _set.lostConnect, _set.disableOnStart], caption: this.capBtnBookmarks, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -196,8 +202,8 @@ define([ parentEl: $host.find('#slot-btn-caption'), cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-caption', + lock: [_set.inHeader, _set.lostConnect, _set.disableOnStart], caption: this.capBtnCaption, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -208,8 +214,8 @@ define([ parentEl: $host.find('#slot-btn-crossref'), cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-cross-reference', + lock: [_set.paragraphLock, _set.headerLock, _set.controlPlain, _set.richEditLock, _set.plainEditLock, _set.contentLock, _set.lostConnect, _set.disableOnStart], caption: this.capBtnCrossRef, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -220,8 +226,8 @@ define([ parentEl: $host.find('#slot-btn-tof'), cls: 'btn-toolbar', iconCls: 'toolbar__icon btn-contents', + lock: [_set.inHeader, _set.richEditLock, _set.plainEditLock, _set.richDelLock, _set.plainDelLock, _set.lostConnect, _set.disableOnStart], caption: this.capBtnTOF, - disabled: true, dataHint: '1', dataHintDirection: 'left', dataHintOffset: 'medium' @@ -232,14 +238,14 @@ define([ parentEl: $host.find('#slot-btn-tof-update'), cls: 'btn-toolbar', iconCls: 'toolbar__icon btn-update', + lock: [_set.paragraphLock, _set.inHeader, _set.richEditLock, _set.plainEditLock, _set.richDelLock, _set.plainDelLock, _set.cantUpdateTOF, _set.lostConnect, _set.disableOnStart], caption: this.capBtnContentsUpdate, - disabled: true, dataHint: '1', dataHintDirection: 'left', dataHintOffset: 'medium' }); this.paragraphControls.push(this.btnTableFiguresUpdate); - + Common.Utils.lockControls(DE.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 65033dfde..d8ee96964 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -80,6 +80,7 @@ define([ dropcapLock: 'dropcap-lock', docPropsLock: 'doc-props-lock', docSchemaLock: 'doc-schema-lock', + hyperlinkLock: 'can-hyperlink', inSmartart: 'in-smartart', inSmartartInternal: 'in-smartart-internal', inSpecificForm: 'in-specific-form', @@ -88,8 +89,10 @@ define([ inHeader: 'in-header', inImage: 'in-image', inImagePara: 'in-image-para', + inImageInline: 'in-image-inline', inFootnote: 'in-footnote', inControl: 'in-control', + inLightTheme: 'light-theme', controlPlain: 'control-plain', noParagraphSelected: 'no-paragraph', cantAddTable: 'cant-add-table', @@ -100,6 +103,11 @@ define([ cantAddChart: 'cant-add-chart', cantAddPageNum: 'cant-add-page-num', cantPageBreak: 'cant-page-break', + cantUpdateTOF: 'cant-update-tof', + cantGroup: 'cant-group', + cantWrap: 'cant-wrap', + cantArrange: 'cant-arrange', + noObjectSelected: 'no-object', lostConnect: 'disconnect', disableOnStart: 'on-start' }; @@ -1281,7 +1289,7 @@ define([ me.btnImgAlign = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-img-align', - lock: [_set.lostConnect, _set.disableOnStart], + lock: [_set.imageLock, _set.contentLock, _set.inImageInline, _set.noObjectSelected, _set.lostConnect, _set.disableOnStart], caption: me.capImgAlign, menu: true, dataHint: '1', @@ -1292,7 +1300,7 @@ define([ me.btnImgGroup = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-img-group', - lock: [_set.lostConnect, _set.disableOnStart], + lock: [_set.imageLock, _set.contentLock, _set.inImageInline, _set.noObjectSelected, _set.cantGroup, _set.lostConnect, _set.disableOnStart], caption: me.capImgGroup, menu: true, dataHint: '1', @@ -1302,7 +1310,7 @@ define([ me.btnImgForward = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-img-frwd', - lock: [_set.lostConnect, _set.disableOnStart], + lock: [_set.cantArrange, _set.lostConnect, _set.contentLock, _set.noObjectSelected, _set.inSmartartInternal, _set.disableOnStart], caption: me.capImgForward, split: true, menu: true, @@ -1313,7 +1321,7 @@ define([ me.btnImgBackward = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-img-bkwd', - lock: [_set.lostConnect, _set.disableOnStart], + lock: [_set.cantArrange, _set.lostConnect, _set.contentLock, _set.noObjectSelected, _set.inSmartartInternal, _set.disableOnStart], caption: me.capImgBackward, split: true, menu: true, @@ -1324,7 +1332,7 @@ define([ me.btnImgWrapping = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-img-wrap', - lock: [_set.lostConnect, _set.disableOnStart], + lock: [_set.cantWrap, _set.imageLock, _set.contentLock, _set.noObjectSelected, _set.lostConnect, _set.disableOnStart], caption: me.capImgWrapping, menu: true, dataHint: '1', diff --git a/apps/documenteditor/main/app/view/ViewTab.js b/apps/documenteditor/main/app/view/ViewTab.js index ce54da4e9..18bb46fe9 100644 --- a/apps/documenteditor/main/app/view/ViewTab.js +++ b/apps/documenteditor/main/app/view/ViewTab.js @@ -85,14 +85,15 @@ define([ var me = this, $host = me.toolbar.$el; + var _set = DE.enumLock; this.btnNavigation = new Common.UI.Button({ parentEl: $host.find('#slot-btn-navigation'), cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-menu-navigation', + lock: [_set.lostConnect, _set.disableOnStart], caption: this.textNavigation, enableToggle: true, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -102,9 +103,9 @@ define([ this.cmbZoom = new Common.UI.ComboBox({ el: $host.find('#slot-field-zoom'), cls: 'input-group-nr', + lock: [_set.lostConnect, _set.disableOnStart], menuStyle: 'min-width: 55px;', editable: true, - disabled: true, data: [ { displayValue: "50%", value: 50 }, { displayValue: "75%", value: 75 }, @@ -130,10 +131,10 @@ define([ parentEl: $host.find('#slot-btn-ftp'), cls: 'btn-toolbar', iconCls: 'toolbar__icon btn-ic-zoomtopage', + lock: [_set.lostConnect, _set.disableOnStart], caption: this.textFitToPage, toggleGroup: 'view-zoom', enableToggle: true, - disabled: true, dataHint: '1', dataHintDirection: 'left', dataHintOffset: 'medium' @@ -144,10 +145,10 @@ define([ parentEl: $host.find('#slot-btn-ftw'), cls: 'btn-toolbar', iconCls: 'toolbar__icon btn-ic-zoomtowidth', + lock: [_set.lostConnect, _set.disableOnStart], caption: this.textFitToWidth, toggleGroup: 'view-zoom', enableToggle: true, - disabled: true, dataHint: '1', dataHintDirection: 'left', dataHintOffset: 'medium' @@ -158,9 +159,9 @@ define([ parentEl: $host.find('#slot-btn-interface-theme'), cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon day', + lock: [_set.lostConnect, _set.disableOnStart], caption: this.textInterfaceTheme, menu: true, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -171,9 +172,9 @@ define([ parentEl: $host.find('#slot-btn-dark-document'), cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon dark-mode', + lock: [_set.inLightTheme, _set.lostConnect, _set.disableOnStart], caption: this.textDarkDocument, enableToggle: true, - disabled: true, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -182,9 +183,9 @@ define([ this.chStatusbar = new Common.UI.CheckBox({ el: $host.findById('#slot-chk-statusbar'), + lock: [_set.lostConnect, _set.disableOnStart], labelText: this.textStatusBar, value: !Common.localStorage.getBool("de-hidden-status"), - disabled: true, dataHint: '1', dataHintDirection: 'left', dataHintOffset: 'small' @@ -193,9 +194,9 @@ define([ this.chToolbar = new Common.UI.CheckBox({ el: $host.findById('#slot-chk-toolbar'), + lock: [_set.lostConnect, _set.disableOnStart], labelText: this.textAlwaysShowToolbar, value: !options.compactToolbar, - disabled: true, dataHint : '1', dataHintDirection: 'left', dataHintOffset: 'small' @@ -204,14 +205,15 @@ define([ this.chRulers = new Common.UI.CheckBox({ el: $host.findById('#slot-chk-rulers'), + lock: [_set.lostConnect, _set.disableOnStart], labelText: this.textRulers, value: !Common.Utils.InternalSettings.get("de-hidden-rulers"), - disabled: true, dataHint: '1', dataHintDirection: 'left', dataHintOffset: 'small' }); this.lockedControls.push(this.chRulers); + Common.Utils.lockControls(_set.disableOnStart, true, {array: this.lockedControls}); }, render: function (el) {