Skip to content

Commit

Permalink
[PDF] Lock buttons in InsTab
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaRadzhabova committed Mar 18, 2024
1 parent 04e6f2e commit e4b1790
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
49 changes: 49 additions & 0 deletions apps/pdfeditor/main/app/controller/InsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion apps/pdfeditor/main/app/view/InsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e4b1790

Please sign in to comment.