[DE] Refactoring toolbar locking: use lock option

This commit is contained in:
Julia Radzhabova 2021-12-28 16:39:43 +03:00
parent db8c10ddb3
commit bb40bc8994
3 changed files with 232 additions and 133 deletions

View file

@ -881,7 +881,7 @@ Common.Utils.lockControls = function(causes, lock, opts, defControls) {
opts.merge && (controls = _.union(defControls,controls));
function doLock(cmp, cause) {
if ( cmp && _.contains(cmp.options.lock, cause) ) {
if ( cmp && cmp.options && _.contains(cmp.options.lock, cause) ) {
var index = cmp.keepState.indexOf(cause);
if (lock) {
if (index < 0) {

View file

@ -503,12 +503,12 @@ define([
onApiCanRevert: function(which, can) {
if (which=='undo') {
if (this._state.can_undo !== can) {
this.toolbar.btnUndo.setDisabled(!can);
this.toolbar.lockToolbar(DE.enumLock.undoLock, !can, {array: [this.toolbar.btnUndo]});
this._state.can_undo = can;
}
} else {
if (this._state.can_redo !== can) {
this.toolbar.btnRedo.setDisabled(!can);
this.toolbar.lockToolbar(DE.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.btnCopy.setDisabled(!can);
this.toolbar.lockToolbar(DE.enumLock.copyLock, !can, {array: [this.toolbar.btnCopy]});
this._state.can_copycut = can;
}
},
@ -725,18 +725,21 @@ define([
plain_del_lock = (frame_pr) ? !frame_pr.can_DeleteInlineContentControl() : false,
plain_edit_lock = (frame_pr) ? !frame_pr.can_EditInlineContentControl() : false;
var need_disable = !this.api.can_AddQuotedComment() || paragraph_locked || header_locked || image_locked || rich_del_lock || rich_edit_lock || plain_del_lock || plain_edit_lock;
if (this.mode.compatibleFeatures) {
need_disable = need_disable || in_image;
}
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});
if (this.api.asc_IsContentControl()) {
var control_props = this.api.asc_GetContentControlProperties(),
spectype = control_props ? control_props.get_SpecificType() : Asc.c_oAscContentControlSpecificType.None;
need_disable = need_disable || 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;
this.toolbar.lockToolbar(DE.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});
}
if ( this.btnsComment && this.btnsComment.length > 0 )
this.btnsComment.setDisabled(need_disable);
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});
},
onApiFocusObject: function(selectedObjects) {
@ -759,7 +762,8 @@ define([
btn_eq_state = false,
in_image = false,
in_control = false,
in_para = false;
in_para = false,
in_footnote = this.api.asc_IsCursorInFootnote() || this.api.asc_IsCursorInEndnote();
while (++i < selectedObjects.length) {
type = selectedObjects[i].get_ObjectType();
@ -802,17 +806,25 @@ define([
var rich_del_lock = (frame_pr) ? !frame_pr.can_DeleteBlockContentControl() : false,
rich_edit_lock = (frame_pr) ? !frame_pr.can_EditBlockContentControl() : false,
plain_del_lock = (frame_pr) ? !frame_pr.can_DeleteInlineContentControl() : false,
plain_edit_lock = (frame_pr) ? !frame_pr.can_EditInlineContentControl() : false;
var need_disable = paragraph_locked || header_locked || rich_edit_lock || plain_edit_lock;
plain_edit_lock = (frame_pr) ? !frame_pr.can_EditInlineContentControl() : false,
in_smart_art = shape_pr && shape_pr.asc_getFromSmartArt(),
in_smart_art_internal = shape_pr && shape_pr.asc_getFromSmartArtInternal();
if (this._state.prcontrolsdisable != need_disable) {
if (this._state.activated) this._state.prcontrolsdisable = need_disable;
_.each (toolbar.paragraphControls, function(item){
item.setDisabled(need_disable);
}, this);
}
toolbar.btnDecLeftOffset.setDisabled(need_disable || shape_pr && shape_pr.asc_getFromSmartArtInternal());
toolbar.btnIncLeftOffset.setDisabled(need_disable || 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(DE.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,
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,
toolbar.btnInsertText, toolbar.btnInsertTextArt, toolbar.btnInsertImage, toolbar.btnSuperscript, toolbar.btnSubscript, toolbar.btnEditHeader])});
in_control = this.api.asc_IsContentControl();
var control_props = in_control ? this.api.asc_GetContentControlProperties() : null,
@ -821,8 +833,7 @@ define([
(lock_type===undefined) && (lock_type = Asc.c_oAscSdtLockType.Unlocked);
var content_locked = lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.ContentLocked;
toolbar.btnContentControls.setDisabled(paragraph_locked || header_locked);
if (!(paragraph_locked || header_locked)) {
if (!toolbar.btnContentControls.isDisabled()) {
var control_disable = control_plain || content_locked,
if_form = control_props && control_props.get_FormPr();
for (var i=0; i<7; i++)
@ -831,18 +842,8 @@ define([
toolbar.btnContentControls.menu.items[10].setDisabled(!in_control || if_form);
}
var need_text_disable = paragraph_locked || header_locked || in_chart || rich_edit_lock || plain_edit_lock || shape_pr && (shape_pr.asc_getFromSmartArt() || shape_pr.asc_getFromSmartArtInternal());
if (this._state.textonlycontrolsdisable != need_text_disable) {
if (this._state.activated) this._state.textonlycontrolsdisable = need_text_disable;
if (!need_disable) {
_.each (toolbar.textOnlyControls, function(item){
item.setDisabled(need_text_disable);
}, this);
}
// toolbar.btnCopyStyle.setDisabled(need_text_disable);
toolbar.btnClearStyle.setDisabled(need_text_disable);
}
this.toolbar.lockToolbar(DE.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(),
drop_value = Asc.c_oAscDropCap.None;
@ -858,79 +859,49 @@ define([
if (enable_dropcap)
this.onDropCap(drop_value);
}
need_disable = need_disable || !enable_dropcap || in_equation || control_plain;
toolbar.btnDropCap.setDisabled(need_disable);
this.toolbar.lockToolbar(DE.enumLock.dropcapLock, !enable_dropcap, {array: [toolbar.btnDropCap]});
if ( !toolbar.btnDropCap.isDisabled() )
toolbar.mnuDropCapAdvanced.setDisabled(disable_dropcapadv);
need_disable = !can_add_table || header_locked || in_equation || control_plain || rich_edit_lock || plain_edit_lock || rich_del_lock || plain_del_lock;
toolbar.btnInsertTable.setDisabled(need_disable);
need_disable = toolbar.mnuPageNumCurrentPos.isDisabled() && toolbar.mnuPageNumberPosPicker.isDisabled() || control_plain;
toolbar.mnuInsertPageNum.setDisabled(need_disable);
var in_footnote = this.api.asc_IsCursorInFootnote() || this.api.asc_IsCursorInEndnote();
need_disable = paragraph_locked || header_locked || in_header || in_image || in_equation && !btn_eq_state || in_footnote || in_control || rich_edit_lock || plain_edit_lock || rich_del_lock || plain_del_lock;
toolbar.btnsPageBreak.setDisabled(need_disable);
toolbar.btnBlankPage.setDisabled(need_disable);
need_disable = paragraph_locked || header_locked || in_equation || control_plain || content_locked || in_footnote;
toolbar.btnInsertShape.setDisabled(need_disable);
toolbar.btnInsertText.setDisabled(need_disable);
need_disable = paragraph_locked || header_locked || in_para && !can_add_image || in_equation || control_plain || rich_del_lock || plain_del_lock || content_locked;
toolbar.btnInsertImage.setDisabled(need_disable);
toolbar.btnInsertTextArt.setDisabled(need_disable || in_footnote);
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]});
if (in_chart !== this._state.in_chart) {
toolbar.btnInsertChart.updateHint(in_chart ? toolbar.tipChangeChart : toolbar.tipInsertChart);
this._state.in_chart = in_chart;
}
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]});
need_disable = in_chart && image_locked || !in_chart && need_disable || control_plain || rich_del_lock || plain_del_lock || content_locked;
toolbar.btnInsertChart.setDisabled(need_disable);
need_disable = paragraph_locked || header_locked || in_chart || !can_add_image&&!in_equation || control_plain || rich_edit_lock || plain_edit_lock || rich_del_lock || plain_del_lock;
toolbar.btnInsertEquation.setDisabled(need_disable);
toolbar.btnInsertSymbol.setDisabled(!in_para || paragraph_locked || header_locked || rich_edit_lock || plain_edit_lock || rich_del_lock || plain_del_lock);
toolbar.btnInsDateTime.setDisabled(!in_para || paragraph_locked || header_locked || rich_edit_lock || plain_edit_lock || rich_del_lock || plain_del_lock);
need_disable = paragraph_locked || header_locked || in_equation || rich_edit_lock || plain_edit_lock;
toolbar.btnSuperscript.setDisabled(need_disable);
toolbar.btnSubscript.setDisabled(need_disable);
toolbar.btnEditHeader.setDisabled(in_equation);
need_disable = paragraph_locked || header_locked || in_image || control_plain || rich_edit_lock || plain_edit_lock || this._state.lock_doc;
if (need_disable != toolbar.btnColumns.isDisabled())
toolbar.btnColumns.setDisabled(need_disable);
toolbar.btnLineNumbers.setDisabled(in_image && in_para || this._state.lock_doc);
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]});
if (toolbar.listStylesAdditionalMenuItem && (frame_pr===undefined) !== toolbar.listStylesAdditionalMenuItem.isDisabled())
toolbar.listStylesAdditionalMenuItem.setDisabled(frame_pr===undefined);
need_disable = !this.api.can_AddQuotedComment() || paragraph_locked || header_locked || image_locked || rich_del_lock || rich_edit_lock || plain_del_lock || plain_edit_lock;
if (this.mode.compatibleFeatures) {
need_disable = need_disable || in_image;
}
// 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});
if (control_props) {
var spectype = control_props.get_SpecificType();
need_disable = need_disable || 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;
this.toolbar.lockToolbar(DE.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});
}
if ( this.btnsComment && this.btnsComment.length > 0 )
this.btnsComment.setDisabled(need_disable);
toolbar.btnWatermark.setDisabled(header_locked);
if (frame_pr) {
this._state.suppress_num = !!frame_pr.get_SuppressLineNumbers();
}
this._state.in_equation = in_equation;
},
@ -973,38 +944,34 @@ define([
onApiLockDocumentProps: function() {
if (this._state.lock_doc!==true) {
this.toolbar.btnPageOrient.setDisabled(true);
this.toolbar.btnPageSize.setDisabled(true);
this.toolbar.btnPageMargins.setDisabled(true);
this.toolbar.lockToolbar(DE.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.btnPageOrient.setDisabled(false);
this.toolbar.btnPageSize.setDisabled(false);
this.toolbar.btnPageMargins.setDisabled(false);
this.toolbar.lockToolbar(DE.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.btnColorSchemas.setDisabled(true);
this.toolbar.lockToolbar(DE.enumLock.docSchemaLock, true, {array: [this.toolbar.btnColorSchemas]});
},
onApiUnLockDocumentSchema: function() {
this.toolbar.btnColorSchemas.setDisabled(false);
this.toolbar.lockToolbar(DE.enumLock.docSchemaLock, false, {array: [this.toolbar.btnColorSchemas]});
},
onApiLockHeaderFooters: function() {
this.toolbar.mnuPageNumberPosPicker.setDisabled(true);
this.toolbar.mnuInsertPageNum.setDisabled(this.toolbar.mnuPageNumCurrentPos.isDisabled());
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]});
},
onApiUnLockHeaderFooters: function() {
this.toolbar.mnuPageNumberPosPicker.setDisabled(false);
this.toolbar.mnuInsertPageNum.setDisabled(false);
this.toolbar.lockToolbar(DE.enumLock.headerFooterLock, false, {array: [this.toolbar.mnuPageNumberPosPicker]});
this.toolbar.lockToolbar(DE.enumLock.cantAddPageNum, false, {array: [this.toolbar.mnuInsertPageNum]});
},
onApiZoomChange: function(percent, type) {},
@ -2903,15 +2870,12 @@ define([
},
activateControls: function() {
_.each(this.toolbar.toolbarControls, function(item){
item.setDisabled(false);
}, this);
this.toolbar.btnUndo.setDisabled(this._state.can_undo!==true);
this.toolbar.btnRedo.setDisabled(this._state.can_redo!==true);
this.toolbar.btnCopy.setDisabled(this._state.can_copycut!==true);
this.toolbar.btnPrint.setDisabled(!this.toolbar.mode.canPrint);
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]});
if (!this._state.mmdisable) {
this.toolbar.btnMailRecepients.setDisabled(false);
this.toolbar.mnuMailRecepients.items[2].setVisible(this.toolbar.mode.fileChoiceUrl || this.toolbar.mode.canRequestMailMergeRecipients);
}
this._state.activated = true;
@ -2922,7 +2886,7 @@ define([
DisableMailMerge: function() {
this._state.mmdisable = true;
this.toolbar && this.toolbar.btnMailRecepients && this.toolbar.btnMailRecepients.setDisabled(true);
this.toolbar && this.toolbar.btnMailRecepients && this.toolbar.lockToolbar(DE.enumLock.mmergeLock, true, {array: [this.toolbar.btnMailRecepients]});
},
updateThemeColors: function() {
@ -3235,11 +3199,11 @@ define([
var links = me.getApplication().getController('Links');
links.setApi(me.api).setConfig({toolbar: me});
Array.prototype.push.apply(me.toolbar.toolbarControls, links.getView('Links').getButtons());
Array.prototype.push.apply(me.toolbar.lockControls, links.getView('Links').getButtons());
var viewtab = me.getApplication().getController('ViewTab');
viewtab.setApi(me.api).setConfig({toolbar: me, mode: config});
Array.prototype.push.apply(me.toolbar.toolbarControls, viewtab.getView('ViewTab').getButtons());
Array.prototype.push.apply(me.toolbar.lockControls, viewtab.getView('ViewTab').getButtons());
}
if ( config.isEdit && config.canFeatureContentControl && config.canFeatureForms || config.isRestrictedEdit && config.canFillForms ) {
if (config.isFormCreator) {
@ -3250,7 +3214,7 @@ define([
if ($panel) {
me.toolbar.addTab(tab, $panel, 4);
me.toolbar.setVisible('forms', true);
config.isEdit && config.canFeatureContentControl && config.canFeatureForms && Array.prototype.push.apply(me.toolbar.toolbarControls, forms.getView('FormsTab').getButtons());
config.isEdit && config.canFeatureContentControl && config.canFeatureForms && Array.prototype.push.apply(me.toolbar.lockControls, forms.getView('FormsTab').getButtons());
!compactview && (config.isFormCreator || config.isRestrictedEdit && config.canFillForms) && me.toolbar.setTab('forms');
}
}
@ -3263,7 +3227,10 @@ define([
me.appOptions = config;
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, undefined, undefined, undefined, undefined, '1', 'bottom');
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],
undefined, undefined, undefined, '1', 'bottom');
if ( this.btnsComment.length ) {
var _comments = DE.getController('Common.Controllers.Comments').getView();
this.btnsComment.forEach(function (btn) {
@ -3275,6 +3242,7 @@ define([
btn.setCaption(me.toolbar.capBtnAddComment);
}, this);
}
Array.prototype.push.apply(this.toolbar.paragraphControls, this.btnsComment);
}
(new Promise(function(accept) {

View file

@ -62,6 +62,48 @@ define([
], function ($, _, Backbone, template, template_view) {
'use strict';
DE.enumLock = {
undoLock: 'can-undo',
redoLock: 'can-redo',
copyLock: 'can-copy',
paragraphLock: 'para-lock',
headerLock: 'header-lock',
headerFooterLock: 'header-footer-lock',
chartLock: 'chart-lock',
imageLock: 'image-lock',
richEditLock: 'rich-edit-lock',
plainEditLock: 'plain-edit-lock',
richDelLock: 'rich-del-lock',
plainDelLock: 'plain-del-lock',
contentLock: 'content-lock',
mmergeLock: 'mmerge-lock',
dropcapLock: 'dropcap-lock',
docPropsLock: 'doc-props-lock',
docSchemaLock: 'doc-schema-lock',
inSmartart: 'in-smartart',
inSmartartInternal: 'in-smartart-internal',
inSpecificForm: 'in-specific-form',
inChart: 'in-chart',
inEquation: 'in-equation',
inHeader: 'in-header',
inImage: 'in-image',
inImagePara: 'in-image-para',
inFootnote: 'in-footnote',
inControl: 'in-control',
controlPlain: 'control-plain',
noParagraphSelected: 'no-paragraph',
cantAddTable: 'cant-add-table',
cantAddQuotedComment: 'cant-add-quoted-comment',
cantPrint: 'cant-print',
cantAddImagePara: 'cant-add-image-para',
cantAddEquation: 'cant-add-equation',
cantAddChart: 'cant-add-chart',
cantAddPageNum: 'cant-add-page-num',
cantPageBreak: 'cant-page-break',
lostConnect: 'disconnect',
disableOnStart: 'on-start'
};
DE.Views.Toolbar = Common.UI.Mixtbar.extend(_.extend((function(){
return {
@ -104,7 +146,8 @@ define([
applyLayout: function (config) {
var me = this;
me.lockControls = [];
var _set = DE.enumLock;
if ( config.isEdit ) {
Common.UI.Mixtbar.prototype.initialize.call(this, {
template: _.template(template),
@ -127,6 +170,7 @@ define([
id: 'id-toolbar-btn-print',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-print no-mask',
lock: [_set.cantPrint, _set.disableOnStart],
signals: ['disabled'],
dataHint: '1',
dataHintDirection: 'top',
@ -138,6 +182,7 @@ define([
id: 'id-toolbar-btn-save',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon no-mask ' + this.btnSaveCls,
lock: [_set.lostConnect, _set.disableOnStart],
signals: ['disabled'],
dataHint: '1',
dataHintDirection: 'bottom',
@ -150,6 +195,7 @@ define([
id: 'id-toolbar-btn-undo',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-undo',
lock: [_set.undoLock, _set.lostConnect, _set.disableOnStart],
signals: ['disabled'],
dataHint: '1',
dataHintDirection: 'bottom',
@ -161,6 +207,7 @@ define([
id: 'id-toolbar-btn-redo',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-redo',
lock: [_set.redoLock, _set.lostConnect, _set.disableOnStart],
signals: ['disabled'],
dataHint: '1',
dataHintDirection: 'bottom',
@ -172,6 +219,7 @@ define([
id: 'id-toolbar-btn-copy',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-copy',
lock: [_set.copyLock, _set.lostConnect, _set.disableOnStart],
dataHint: '1',
dataHintDirection: 'top',
dataHintTitle: 'C'
@ -182,6 +230,7 @@ define([
id: 'id-toolbar-btn-paste',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-paste',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
dataHint: '1',
dataHintDirection: 'top',
dataHintTitle: 'V'
@ -192,6 +241,7 @@ define([
id: 'id-toolbar-btn-incfont',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-incfont',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
dataHint: '1',
dataHintDirection: 'top'
});
@ -201,6 +251,7 @@ define([
id: 'id-toolbar-btn-decfont',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-decfont',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
dataHint: '1',
dataHintDirection: 'top'
});
@ -210,6 +261,7 @@ define([
id: 'id-toolbar-btn-bold',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-bold',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
enableToggle: true,
dataHint: '1',
dataHintDirection: 'bottom'
@ -220,6 +272,7 @@ define([
id: 'id-toolbar-btn-italic',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-italic',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
enableToggle: true,
dataHint: '1',
dataHintDirection: 'bottom'
@ -230,6 +283,7 @@ define([
id: 'id-toolbar-btn-underline',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-underline',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
enableToggle: true,
dataHint: '1',
dataHintDirection: 'bottom'
@ -240,6 +294,7 @@ define([
id: 'id-toolbar-btn-strikeout',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-strikeout',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
enableToggle: true,
dataHint: '1',
dataHintDirection: 'bottom'
@ -250,6 +305,7 @@ define([
id: 'id-toolbar-btn-superscript',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-superscript',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inEquation, _set.lostConnect, _set.disableOnStart],
enableToggle: true,
toggleGroup: 'superscriptGroup',
dataHint: '1',
@ -261,6 +317,7 @@ define([
id: 'id-toolbar-btn-subscript',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-subscript',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inEquation, _set.lostConnect, _set.disableOnStart],
enableToggle: true,
toggleGroup: 'superscriptGroup',
dataHint: '1',
@ -272,6 +329,7 @@ define([
id: 'id-toolbar-btn-highlight',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-highlight',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inChart, _set.inSmartart, _set.inSmartartInternal, _set.lostConnect, _set.disableOnStart],
enableToggle: true,
allowDepress: true,
split: true,
@ -297,6 +355,7 @@ define([
id: 'id-toolbar-btn-fontcolor',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-fontcolor',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
split: true,
menu: true,
auto: true,
@ -310,6 +369,7 @@ define([
id: 'id-toolbar-btn-paracolor',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-paracolor',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inChart, _set.inSmartart, _set.inSmartartInternal, _set.lostConnect, _set.disableOnStart],
split: true,
transparent: true,
menu: true,
@ -324,6 +384,7 @@ define([
id: 'id-toolbar-btn-case',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-change-case',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
menu: new Common.UI.Menu({
items: [
{caption: this.mniSentenceCase, value: Asc.c_oAscChangeTextCaseType.SentenceCase},
@ -342,6 +403,7 @@ define([
id: 'id-toolbar-btn-align-left',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-align-left',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
enableToggle: true,
toggleGroup: 'alignGroup',
dataHint: '1',
@ -353,6 +415,7 @@ define([
id: 'id-toolbar-btn-align-center',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-align-center',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
enableToggle: true,
toggleGroup: 'alignGroup',
dataHint: '1',
@ -364,6 +427,7 @@ define([
id: 'id-toolbar-btn-align-right',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-align-right',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
enableToggle: true,
toggleGroup: 'alignGroup',
dataHint: '1',
@ -375,6 +439,7 @@ define([
id: 'id-toolbar-btn-align-just',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-align-just',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
enableToggle: true,
toggleGroup: 'alignGroup',
dataHint: '1',
@ -386,6 +451,7 @@ define([
id: 'id-toolbar-btn-decoffset',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-decoffset',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inSmartartInternal, _set.lostConnect, _set.disableOnStart],
dataHint: '1',
dataHintDirection: 'top'
});
@ -395,6 +461,7 @@ define([
id: 'id-toolbar-btn-incoffset',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-incoffset',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inSmartartInternal, _set.lostConnect, _set.disableOnStart],
dataHint: '1',
dataHintDirection: 'top'
});
@ -404,6 +471,7 @@ define([
id: 'id-toolbar-btn-linespace',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-linespace',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
menu: new Common.UI.Menu({
style: 'min-width: 60px;',
items: [
@ -425,6 +493,7 @@ define([
id: 'id-toolbar-btn-hidenchars',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-paragraph',
lock: [_set.lostConnect, _set.disableOnStart],
enableToggle: true,
split: true,
menu: new Common.UI.Menu({
@ -444,6 +513,7 @@ define([
id: 'id-toolbar-btn-markers',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-setmarkers',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inChart, _set.inSmartart, _set.inSmartartInternal, _set.lostConnect, _set.disableOnStart],
enableToggle: true,
toggleGroup: 'markersGroup',
split: true,
@ -459,6 +529,7 @@ define([
id: 'id-toolbar-btn-numbering',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-numbering',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inChart, _set.inSmartart, _set.inSmartartInternal, _set.lostConnect, _set.disableOnStart],
enableToggle: true,
toggleGroup: 'markersGroup',
split: true,
@ -474,6 +545,7 @@ define([
id: 'id-toolbar-btn-multilevels',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-multilevels',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inChart, _set.inSmartart, _set.inSmartartInternal, _set.lostConnect, _set.disableOnStart],
menu: true,
dataHint: '1',
dataHintDirection: 'top',
@ -505,6 +577,7 @@ define([
id: 'tlbtn-inserttable',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-inserttable',
lock: [_set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inEquation, _set.controlPlain, _set.richDelLock, _set.plainDelLock, _set.cantAddTable, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnInsTable,
menu: new Common.UI.Menu({
items: [
@ -525,6 +598,7 @@ define([
id: 'tlbtn-insertimage',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-insertimage',
lock: [_set.paragraphLock, _set.headerLock, _set.inEquation, _set.controlPlain, _set.richDelLock, _set.plainDelLock, _set.contentLock, _set.cantAddImagePara, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnInsImage,
menu: new Common.UI.Menu({
items: [
@ -544,6 +618,8 @@ define([
cls: 'btn-toolbar x-huge icon-top',
caption: me.capBtnInsChart,
iconCls: 'toolbar__icon btn-insertchart',
lock: [ _set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.controlPlain, _set.richDelLock, _set.plainDelLock, _set.contentLock,
_set.chartLock, _set.cantAddChart, _set.lostConnect, _set.disableOnStart],
menu: true,
dataHint: '1',
dataHintDirection: 'bottom',
@ -555,6 +631,7 @@ define([
id: 'tlbtn-inserttext',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-text',
lock: [_set.paragraphLock, _set.headerLock, _set.inEquation, _set.controlPlain, _set.contentLock, _set.inFootnote, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnInsTextbox,
enableToggle: true,
dataHint: '1',
@ -562,10 +639,12 @@ define([
dataHintOffset: 'small'
});
this.paragraphControls.push(this.btnInsertText);
this.btnInsertTextArt = new Common.UI.Button({
id: 'tlbtn-inserttextart',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-textart',
lock: [_set.paragraphLock, _set.headerLock, _set.inEquation, _set.controlPlain, _set.richDelLock, _set.plainDelLock, _set.contentLock, _set.inFootnote, _set.cantAddImagePara, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnInsTextart,
menu: new Common.UI.Menu({
cls: 'menu-shapes',
@ -583,12 +662,15 @@ define([
id: 'id-toolbar-btn-editheader',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-editheader',
lock: [_set.inEquation, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnInsHeader,
menu: true,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
this.toolbarControls.push(this.btnEditHeader);
this.mnuPageNumberPosPicker = {
conf: {disabled: false},
isDisabled: function () {
@ -596,19 +678,24 @@ define([
},
setDisabled: function (val) {
this.conf.disabled = val;
}
},
options: {}
};
this.mnuPageNumCurrentPos = clone(this.mnuPageNumberPosPicker);
this.mnuInsertPageNum = clone(this.mnuPageNumberPosPicker);
this.mnuInsertPageCount = clone(this.mnuPageNumberPosPicker);
this.mnuPageNumCurrentPos.options.lock = [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock];
this.paragraphControls.push(this.mnuPageNumCurrentPos);
this.mnuInsertPageCount = clone(this.mnuPageNumberPosPicker);
this.mnuInsertPageCount.options.lock = [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock];
this.paragraphControls.push(this.mnuInsertPageCount);
this.toolbarControls.push(this.btnEditHeader);
this.mnuInsertPageNum = clone(this.mnuPageNumberPosPicker);
this.mnuInsertPageNum.options.lock = [_set.cantAddPageNum, _set.controlPlain];
this.mnuPageNumberPosPicker.options.lock = [_set.headerFooterLock];
this.btnInsDateTime = new Common.UI.Button({
id: 'id-toolbar-btn-datetime',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-datetime',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.richDelLock, _set.plainDelLock, _set.noParagraphSelected, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnDateTime,
dataHint: '1',
dataHintDirection: 'bottom',
@ -620,6 +707,8 @@ define([
id: 'id-toolbar-btn-blankpage',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-blankpage',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inEquation, _set.richDelLock, _set.plainDelLock, _set.inHeader, _set.inFootnote, _set.inControl,
_set.cantPageBreak, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnBlankPage,
dataHint: '1',
dataHintDirection: 'bottom',
@ -631,6 +720,7 @@ define([
id: 'tlbtn-insertshape',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-insertshape',
lock: [_set.paragraphLock, _set.headerLock, _set.inEquation, _set.controlPlain, _set.contentLock, _set.inFootnote, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnInsShape,
enableToggle: true,
menu: new Common.UI.Menu({cls: 'menu-shapes menu-insert-shape'}),
@ -644,6 +734,7 @@ define([
id: 'tlbtn-insertequation',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-insertequation',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inChart, _set.controlPlain, _set.richDelLock, _set.plainDelLock, _set.cantAddEquation, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnInsEquation,
split: true,
menu: new Common.UI.Menu({cls: 'menu-shapes'}),
@ -657,6 +748,7 @@ define([
id: 'tlbtn-insertsymbol',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-symbol',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.richDelLock, _set.plainDelLock, _set.noParagraphSelected, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnInsSymbol,
dataHint: '1',
dataHintDirection: 'bottom',
@ -668,6 +760,7 @@ define([
id: 'tlbtn-dropcap',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-dropcap',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inEquation, _set.controlPlain, _set.dropcapLock, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnInsDropcap,
menu: new Common.UI.Menu({
cls: 'ppm-toolbar shifted-right',
@ -711,6 +804,7 @@ define([
id: 'tlbtn-controls',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-controls',
lock: [_set.paragraphLock, _set.headerLock, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnInsControls,
menu: new Common.UI.Menu({
cls: 'ppm-toolbar shifted-right',
@ -787,12 +881,14 @@ define([
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
this.toolbarControls.push(this.btnContentControls);
// this.paragraphControls.push(this.btnContentControls);
this.btnColumns = new Common.UI.Button({
id: 'tlbtn-columns',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-columns',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.controlPlain, _set.inImage, _set.docPropsLock, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnColumns,
menu: new Common.UI.Menu({
cls: 'ppm-toolbar shifted-right',
@ -851,6 +947,7 @@ define([
id: 'tlbtn-pageorient',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-pageorient',
lock: [_set.docPropsLock, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnPageOrient,
menu: new Common.UI.Menu({
cls: 'ppm-toolbar',
@ -892,6 +989,7 @@ define([
id: 'tlbtn-pagemargins',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-pagemargins',
lock: [_set.docPropsLock, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnMargins,
menu: new Common.UI.Menu({
items: [
@ -954,6 +1052,7 @@ define([
id: 'tlbtn-pagesize',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-pagesize',
lock: [_set.docPropsLock, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnPageSize,
menu: new Common.UI.Menu({
restoreHeight: true,
@ -1077,6 +1176,7 @@ define([
id: 'tlbtn-line-numbers',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-line-numbering',
lock: [_set.docPropsLock, _set.inImagePara, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnLineNumbers,
menu: new Common.UI.Menu({
cls: 'ppm-toolbar',
@ -1128,6 +1228,7 @@ define([
id: 'id-toolbar-btn-clearstyle',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-clearstyle',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inChart, _set.inSmartart, _set.inSmartartInternal, _set.lostConnect, _set.disableOnStart],
dataHint: '1',
dataHintDirection: 'top'
});
@ -1137,6 +1238,7 @@ define([
id: 'id-toolbar-btn-copystyle',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-copystyle',
lock: [_set.lostConnect, _set.disableOnStart],
enableToggle: true,
dataHint: '1',
dataHintDirection: 'bottom'
@ -1147,6 +1249,7 @@ define([
id: 'id-toolbar-btn-colorschemas',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-colorschemas',
lock: [_set.docSchemaLock, _set.lostConnect, _set.disableOnStart],
menu: new Common.UI.Menu({
cls: 'shifted-left',
items: [],
@ -1162,6 +1265,7 @@ define([
id: 'id-toolbar-btn-mailrecepients',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-mailmerge',
lock: [_set.mmergeLock, _set.lostConnect, _set.disableOnStart],
dataHint: '1',
dataHintDirection: 'bottom',
menu: new Common.UI.Menu({
@ -1172,10 +1276,12 @@ define([
]
})
});
this.toolbarControls.push(this.btnMailRecepients);
me.btnImgAlign = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-img-align',
lock: [_set.lostConnect, _set.disableOnStart],
caption: me.capImgAlign,
menu: true,
dataHint: '1',
@ -1186,6 +1292,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],
caption: me.capImgGroup,
menu: true,
dataHint: '1',
@ -1195,6 +1302,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],
caption: me.capImgForward,
split: true,
menu: true,
@ -1205,6 +1313,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],
caption: me.capImgBackward,
split: true,
menu: true,
@ -1215,6 +1324,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],
caption: me.capImgWrapping,
menu: true,
dataHint: '1',
@ -1225,6 +1335,7 @@ define([
me.btnWatermark = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-watermark',
lock: [_set.headerLock, _set.lostConnect, _set.disableOnStart],
caption: me.capBtnWatermark,
menu: new Common.UI.Menu({
cls: 'ppm-toolbar',
@ -1263,6 +1374,7 @@ define([
this.cmbFontSize = new Common.UI.ComboBox({
cls: 'input-group-nr',
menuStyle: 'min-width: 55px;',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
hint: this.tipFontSize,
data: [
{value: 8, displayValue: "8"},
@ -1292,6 +1404,7 @@ define([
cls: 'input-group-nr',
menuCls: 'scrollable-menu',
menuStyle: 'min-width: 325px;',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.lostConnect, _set.disableOnStart],
hint: this.tipFontName,
store: new Common.Collections.Fonts(),
dataHint: '1',
@ -1309,6 +1422,7 @@ define([
itemHeight = 40;
this.listStyles = new Common.UI.ComboDataView({
cls: 'combo-styles',
lock: [_set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.inChart, _set.inSmartart, _set.inSmartartInternal, _set.lostConnect, _set.disableOnStart],
itemWidth: itemWidth,
itemHeight: itemHeight,
// hint : this.tipParagraphStyle,
@ -1366,11 +1480,8 @@ define([
this.textOnlyControls.push(this.listStyles);
// Disable all components before load document
_.each(this.toolbarControls.concat(this.paragraphControls), function (cmp) {
if (_.isFunction(cmp.setDisabled))
cmp.setDisabled(true);
});
this.btnMailRecepients.setDisabled(true);
this.lockControls = me.toolbarControls.concat(me.paragraphControls);
this.lockToolbar(DE.enumLock.disableOnStart, true, {array: this.lockControls});
var editStyleMenuUpdate = new Common.UI.MenuItem({
caption: me.textStyleMenuUpdate
@ -1403,7 +1514,6 @@ define([
]
});
}
this.on('render:after', _.bind(this.onToolbarAfterRender, this));
} else {
Common.UI.Mixtbar.prototype.initialize.call(this, {
@ -1557,8 +1667,12 @@ define([
_injectComponent('#slot-img-wrapping', this.btnImgWrapping);
_injectComponent('#slot-btn-watermark', this.btnWatermark);
this.btnsPageBreak = Common.Utils.injectButtons($host.find('.btn-slot.btn-pagebreak'), '', 'toolbar__icon btn-pagebreak', this.capBtnInsPagebreak, undefined, true, true, undefined, '1', 'bottom', 'small');
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],
true, true, undefined, '1', 'bottom', 'small');
Array.prototype.push.apply(this.paragraphControls, this.btnsPageBreak);
Array.prototype.push.apply(this.lockControls, this.btnsPageBreak);
return $host;
},
@ -1939,6 +2053,9 @@ define([
})
);
var keepStateCurr = this.mnuPageNumCurrentPos.keepState,
keepStateCount = this.mnuInsertPageCount.keepState,
keepStateNum = this.mnuInsertPageNum.keepState;
this.btnEditHeader.setMenu(
new Common.UI.Menu({
items: [
@ -1947,6 +2064,7 @@ define([
{caption: '--'},
this.mnuInsertPageNum = new Common.UI.MenuItem({
caption: this.textInsertPageNumber,
lock: this.mnuInsertPageNum.options.lock,
disabled: this.mnuInsertPageNum.isDisabled(),
menu: new Common.UI.Menu({
cls: 'shifted-left',
@ -1956,6 +2074,7 @@ define([
{template: _.template('<div id="id-toolbar-menu-pageposition" class="menu-pageposition"></div>')},
this.mnuPageNumCurrentPos = new Common.UI.MenuItem({
caption: this.textToCurrent,
lock: this.mnuPageNumCurrentPos.options.lock,
disabled: this.mnuPageNumCurrentPos.isDisabled(),
value: 'current'
})
@ -1964,13 +2083,19 @@ define([
}),
this.mnuInsertPageCount = new Common.UI.MenuItem({
caption: this.textInsertPageCount,
lock: this.mnuInsertPageCount.options.lock,
disabled: this.mnuInsertPageCount.isDisabled()
})
]
})
);
this.mnuInsertPageNum.keepState = keepStateNum;
this.mnuPageNumCurrentPos.keepState = keepStateCurr;
this.paragraphControls.push(this.mnuPageNumCurrentPos);
this.lockControls.push(this.mnuPageNumCurrentPos);
this.mnuInsertPageCount.keepState = keepStateCount;
this.paragraphControls.push(this.mnuInsertPageCount);
this.lockControls.push(this.mnuInsertPageCount);
this.btnInsertChart.setMenu( new Common.UI.Menu({
style: 'width: 364px;padding-top: 12px;',
@ -2086,8 +2211,10 @@ define([
_conf && this.mnuMultilevelPicker.selectByIndex(_conf.index, true);
_conf = this.mnuPageNumberPosPicker ? this.mnuPageNumberPosPicker.conf : undefined;
var keepState = this.mnuPageNumberPosPicker ? this.mnuPageNumberPosPicker.keepState : undefined;
this.mnuPageNumberPosPicker = new Common.UI.DataView({
el: $('#id-toolbar-menu-pageposition'),
lock: this.mnuPageNumberPosPicker.options.lock,
allowScrollbar: false,
parentMenu: this.mnuInsertPageNum.menu,
outerMenu: {menu: this.mnuInsertPageNum.menu, index: 0},
@ -2138,6 +2265,7 @@ define([
]),
itemTemplate: _.template('<div id="<%= id %>" class="item-pagenumber options__icon options__icon-huge <%= iconname %>"></div>')
});
this.mnuPageNumberPosPicker.keepState = keepState;
_conf && this.mnuPageNumberPosPicker.setDisabled(_conf.disabled);
this.mnuInsertPageNum.menu.setInnerMenu([{menu: this.mnuPageNumberPosPicker, index: 0}]);
@ -2236,14 +2364,13 @@ define([
setMode: function (mode) {
if (mode.isDisconnected) {
this.btnSave.setDisabled(true);
this.btnUndo.setDisabled(true);
this.btnRedo.setDisabled(true);
this.lockToolbar(DE.enumLock.lostConnect, true);
if ( this.synchTooltip )
this.synchTooltip.hide();
if (!mode.enableDownload)
this.btnPrint.setDisabled(true);
}
this.lockToolbar(DE.enumLock.cantPrint, true, {array: [this.btnPrint]});
} else
this.lockToolbar(DE.enumLock.cantPrint, !mode.canPrint, {array: [this.btnPrint]});
this.mode = mode;
@ -2424,6 +2551,10 @@ define([
this.api.asc_RemoveAllCustomStyles();
},
lockToolbar: function (causes, lock, opts) {
Common.Utils.lockControls(causes, lock, opts, this.lockControls);
},
textBold: 'Bold',
textItalic: 'Italic',
textUnderline: 'Underline',