diff --git a/apps/documenteditor/main/app/controller/DocumentHolder.js b/apps/documenteditor/main/app/controller/DocumentHolder.js index cbffb7142..d6b3f0ad2 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolder.js +++ b/apps/documenteditor/main/app/controller/DocumentHolder.js @@ -212,6 +212,8 @@ define([ this.api.asc_registerCallback('asc_ChangeCropState', _.bind(this.onChangeCropState, this)); this.api.asc_registerCallback('asc_onLockDocumentProps', _.bind(this.onApiLockDocumentProps, this)); this.api.asc_registerCallback('asc_onUnLockDocumentProps', _.bind(this.onApiUnLockDocumentProps, this)); + this.api.asc_registerCallback('asc_onShowMathTrack', _.bind(this.onShowMathTrack, this)); + this.api.asc_registerCallback('asc_onHideMathTrack', _.bind(this.onHideMathTrack, this)); } this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); @@ -614,9 +616,9 @@ define([ onFocusObject: function(selectedElements) { var me = this, - currentMenu = me.documentHolder.currentMenu, - docProtection = me.documentHolder._docProtection; + currentMenu = me.documentHolder.currentMenu; if (currentMenu && currentMenu.isVisible() && currentMenu !== me.documentHolder.hdrMenu){ + var docProtection = me.documentHolder._docProtection; var obj = (me.mode.isEdit && !(me._isDisabled || docProtection.isReadOnly || docProtection.isFormsOnly || docProtection.isCommentsOnly)) ? me.fillMenuProps(selectedElements) : me.fillViewMenuProps(selectedElements); if (obj) { @@ -626,19 +628,25 @@ define([ } } } - var i = -1, - in_equation = false, - locked = false; - while (++i < selectedElements.length) { - var type = selectedElements[i].get_ObjectType(); - if (type === Asc.c_oAscTypeSelectElement.Math) { - in_equation = true; - } else if (type === Asc.c_oAscTypeSelectElement.Paragraph || type === Asc.c_oAscTypeSelectElement.Table || type === Asc.c_oAscTypeSelectElement.Header) { - var value = selectedElements[i].get_ObjectValue(); - value && (locked = locked || value.get_Locked()); + + if (this.mode && this.mode.isEdit) { + var i = -1, + in_equation = false, + locked = false; + while (++i < selectedElements.length) { + var type = selectedElements[i].get_ObjectType(); + if (type === Asc.c_oAscTypeSelectElement.Math) { + in_equation = true; + } else if (type === Asc.c_oAscTypeSelectElement.Paragraph || type === Asc.c_oAscTypeSelectElement.Table || type === Asc.c_oAscTypeSelectElement.Header) { + var value = selectedElements[i].get_ObjectValue(); + value && (locked = locked || value.get_Locked()); + } + } + if (in_equation) { + this._state.equationLocked = locked; + this.disableEquationBar(); } } - in_equation && me.mode.isEdit && !(me._isDisabled || docProtection.isReadOnly || docProtection.isFormsOnly || docProtection.isCommentsOnly) ? this.onEquationPanelShow(locked) : this.onEquationPanelHide(); }, handleDocumentWheel: function(event) { @@ -1513,6 +1521,7 @@ define([ SetDisabled: function(state, canProtect, fillFormMode) { this._isDisabled = state; this.documentHolder.SetDisabled(state, canProtect, fillFormMode); + this.disableEquationBar(); }, onTextLanguage: function(langid) { @@ -2323,7 +2332,11 @@ define([ return false; }, - onEquationPanelShow: function(disabled) { + onShowMathTrack: function(bounds) { + if (bounds[3] < 0) { + this.onHideMathTrack(); + return; + } var me = this, documentHolder = me.documentHolder, eqContainer = documentHolder.cmpEl.find('#equation-container'); @@ -2378,7 +2391,7 @@ define([ menu : new Common.UI.Menu({ cls: 'menu-shapes', value: i, - // restoreHeight: equationGroup.get('groupHeight') ? parseInt(equationGroup.get('groupHeight')) : true, + restoreHeight: equationGroup.get('groupHeight') ? parseInt(equationGroup.get('groupHeight')) : true, items: [ { template: _.template('