From e4b1790b4a05fc3aabbc2ee43cbbba51972c102a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 18 Mar 2024 12:37:15 +0300 Subject: [PATCH] [PDF] Lock buttons in InsTab --- apps/pdfeditor/main/app/controller/InsTab.js | 49 ++++++++++++++++++++ apps/pdfeditor/main/app/view/InsTab.js | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/apps/pdfeditor/main/app/controller/InsTab.js b/apps/pdfeditor/main/app/controller/InsTab.js index f91f39e638..82db0f0651 100644 --- a/apps/pdfeditor/main/app/controller/InsTab.js +++ b/apps/pdfeditor/main/app/controller/InsTab.js @@ -84,6 +84,8 @@ define([ this.api.asc_registerCallback('asc_onBeginSmartArtPreview', _.bind(this.onApiBeginSmartArtPreview, this)); this.api.asc_registerCallback('asc_onAddSmartArtPreview', _.bind(this.onApiAddSmartArtPreview, this)); this.api.asc_registerCallback('asc_onEndSmartArtPreview', _.bind(this.onApiEndSmartArtPreview, this)); + this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this)); + this.api.asc_registerCallback('asc_onCanAddHyperlink', _.bind(this.onApiCanAddHyperlink, this)); Common.NotificationCenter.on('storage:image-load', _.bind(this.openImageFromStorage, this)); Common.NotificationCenter.on('storage:image-insert', _.bind(this.insertImageFromStorage, this)); Common.Gateway.on('insertimage', _.bind(this.insertImage, this)); @@ -920,6 +922,53 @@ define([ } }, + onApiFocusObject: function(selectedObjects) { + var pr, i = -1, type, + paragraph_locked = false, + no_paragraph = true, + in_chart = false; + + while (++i < selectedObjects.length) { + type = selectedObjects[i].get_ObjectType(); + pr = selectedObjects[i].get_ObjectValue(); + + if (type === Asc.c_oAscTypeSelectElement.Paragraph) { + paragraph_locked = pr.get_Locked(); + no_paragraph = false; + } else if (type == Asc.c_oAscTypeSelectElement.Image || type == Asc.c_oAscTypeSelectElement.Shape || type == Asc.c_oAscTypeSelectElement.Chart || type == Asc.c_oAscTypeSelectElement.Table) { + if (type == Asc.c_oAscTypeSelectElement.Table || + type == Asc.c_oAscTypeSelectElement.Shape && !pr.get_FromImage() && !pr.get_FromChart()) { + no_paragraph = false; + } + if (type == Asc.c_oAscTypeSelectElement.Chart) { + in_chart = true; + } + } + } + + if (in_chart !== this._state.in_chart) { + this.view.btnInsertChart.updateHint(in_chart ? this.view.tipChangeChart : this.view.tipInsertChart); + this._state.in_chart = in_chart; + } + + if (this._state.prcontrolsdisable !== paragraph_locked) { + if (this._state.activated) this._state.prcontrolsdisable = paragraph_locked; + Common.Utils.lockControls(Common.enumLock.paragraphLock, paragraph_locked===true, {array: this.view.lockedControls}); + } + + if (this._state.no_paragraph !== no_paragraph) { + if (this._state.activated) this._state.no_paragraph = no_paragraph; + Common.Utils.lockControls(Common.enumLock.noParagraphSelected, no_paragraph, {array: this.view.lockedControls}); + } + }, + + onApiCanAddHyperlink: function(value) { + if (this._state.can_hyper !== value) { + Common.Utils.lockControls(Common.enumLock.hyperlinkLock, !value, {array: [this.view.btnInsertHyperlink]}); + if (this._state.activated) this._state.can_hyper = value; + } + }, + txtBasicShapes: 'Basic Shapes', txtFiguredArrows: 'Figured Arrows', txtMath: 'Math', diff --git a/apps/pdfeditor/main/app/view/InsTab.js b/apps/pdfeditor/main/app/view/InsTab.js index cfa434dc26..e7f3ac3294 100644 --- a/apps/pdfeditor/main/app/view/InsTab.js +++ b/apps/pdfeditor/main/app/view/InsTab.js @@ -355,7 +355,7 @@ define([ this.btnsInsertText = Common.Utils.injectButtons($host.find('.slot-instext').add(this.toolbar.$el.find('.slot-instext')), 'tlbtn-inserttext-', 'toolbar__icon btn-big-text', this.capInsertText, [Common.enumLock.lostConnect, Common.enumLock.disableOnStart], true, false, true, '1', 'bottom', 'small'); this.btnsInsertShape = Common.Utils.injectButtons($host.find('.slot-insertshape').add(this.toolbar.$el.find('.slot-insertshape')), 'tlbtn-insertshape-', 'toolbar__icon btn-insertshape', this.capInsertShape, - [Common.enumLock.slideDeleted, Common.enumLock.lostConnect, Common.enumLock.noSlides, Common.enumLock.disableOnStart], false, true, true, '1', 'bottom', 'small'); + [Common.enumLock.lostConnect, Common.enumLock.disableOnStart], false, true, true, '1', 'bottom', 'small'); } var created = this.btnsInsertImage.concat(this.btnsInsertText, this.btnsInsertShape);