[DE] Refactoring equation settings, add eq.settings to equation toolbar
This commit is contained in:
parent
cd9f85f2a4
commit
d06d9fd653
|
@ -620,13 +620,18 @@ define([
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var i = -1,
|
var i = -1,
|
||||||
in_equation = false;
|
in_equation = false,
|
||||||
|
locked = false;
|
||||||
while (++i < selectedElements.length) {
|
while (++i < selectedElements.length) {
|
||||||
if (selectedElements[i].get_ObjectType() === Asc.c_oAscTypeSelectElement.Math) {
|
var type = selectedElements[i].get_ObjectType();
|
||||||
|
if (type === Asc.c_oAscTypeSelectElement.Math) {
|
||||||
in_equation = true;
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in_equation ? this.onEquationPanelShow() : this.onEquationPanelHide();
|
in_equation ? this.onEquationPanelShow(locked) : this.onEquationPanelHide();
|
||||||
},
|
},
|
||||||
|
|
||||||
handleDocumentWheel: function(event) {
|
handleDocumentWheel: function(event) {
|
||||||
|
@ -2307,7 +2312,7 @@ define([
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
onEquationPanelShow: function() {
|
onEquationPanelShow: function(disabled) {
|
||||||
var me = this,
|
var me = this,
|
||||||
documentHolder = me.documentHolder,
|
documentHolder = me.documentHolder,
|
||||||
eqContainer = documentHolder.cmpEl.find('#equation-container');
|
eqContainer = documentHolder.cmpEl.find('#equation-container');
|
||||||
|
@ -2324,6 +2329,8 @@ define([
|
||||||
var style = 'margin-right: 8px;' + (i==0 ? 'margin-left: 5px;' : '');
|
var style = 'margin-right: 8px;' + (i==0 ? 'margin-left: 5px;' : '');
|
||||||
eqStr += '<span id="id-document-holder-btn-equation-' + i + '" style="' + style +'"></span>';
|
eqStr += '<span id="id-document-holder-btn-equation-' + i + '" style="' + style +'"></span>';
|
||||||
}
|
}
|
||||||
|
eqStr += '<div class="separator"></div>';
|
||||||
|
eqStr += '<span id="id-document-holder-btn-equation-settings" style="margin-right: 5px; margin-left: 8px;"></span>';
|
||||||
eqStr += '</div>';
|
eqStr += '</div>';
|
||||||
eqContainer = $(eqStr);
|
eqContainer = $(eqStr);
|
||||||
documentHolder.cmpEl.find('#id_main_view').append(eqContainer);
|
documentHolder.cmpEl.find('#id_main_view').append(eqContainer);
|
||||||
|
@ -2371,11 +2378,41 @@ define([
|
||||||
btn.menu.on('show:before', onShowBefore);
|
btn.menu.on('show:before', onShowBefore);
|
||||||
me.equationBtns.push(btn);
|
me.equationBtns.push(btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
me.equationSettingsBtn = new Common.UI.Button({
|
||||||
|
parentEl: $('#id-document-holder-btn-equation-settings', documentHolder.cmpEl),
|
||||||
|
cls : 'btn-toolbar no-caret',
|
||||||
|
iconCls : 'toolbar__icon more-vertical',
|
||||||
|
hint : me.documentHolder.advancedEquationText,
|
||||||
|
menu : me.documentHolder.createEquationMenu('popuptbeqinput', 'tl-bl')
|
||||||
|
});
|
||||||
|
me.equationSettingsBtn.menu.options.initMenu = function() {
|
||||||
|
var eq = me.api.asc_GetMathInputType();
|
||||||
|
var menu = me.equationSettingsBtn.menu;
|
||||||
|
menu.items[0].setChecked(eq===Asc.c_oAscMathInputType.Unicode);
|
||||||
|
menu.items[1].setChecked(eq===Asc.c_oAscMathInputType.LaTeX);
|
||||||
|
menu.items[8].setChecked(me.api.asc_IsInlineMath());
|
||||||
|
};
|
||||||
|
me.equationSettingsBtn.menu.on('item:click', _.bind(me.convertEquation, me));
|
||||||
|
me.equationSettingsBtn.menu.on('show:before', function(menu) {
|
||||||
|
menu.options.initMenu();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var showPoint = [(me._Width - eqContainer.outerWidth())/2, 0];
|
var showPoint = [(me._Width - eqContainer.outerWidth())/2, 0];
|
||||||
eqContainer.css({left: showPoint[0], top : showPoint[1]});
|
eqContainer.css({left: showPoint[0], top : showPoint[1]});
|
||||||
|
if (eqContainer.is(':visible')) {
|
||||||
|
if (me.equationSettingsBtn.menu.isVisible()) {
|
||||||
|
me.equationSettingsBtn.menu.options.initMenu();
|
||||||
|
me.equationSettingsBtn.menu.alignPosition();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
eqContainer.show();
|
eqContainer.show();
|
||||||
|
}
|
||||||
|
me.equationBtns.forEach(function(item){
|
||||||
|
item && item.setDisabled(!!disabled);
|
||||||
|
});
|
||||||
|
me.equationSettingsBtn.setDisabled(!!disabled);
|
||||||
},
|
},
|
||||||
|
|
||||||
onEquationPanelHide: function() {
|
onEquationPanelHide: function() {
|
||||||
|
|
|
@ -1145,64 +1145,7 @@ define([
|
||||||
|
|
||||||
me.menuTableEquation = new Common.UI.MenuItem({
|
me.menuTableEquation = new Common.UI.MenuItem({
|
||||||
caption : me.advancedEquationText,
|
caption : me.advancedEquationText,
|
||||||
menu : new Common.UI.Menu({
|
menu : me.createEquationMenu('popuptableeqinput', 'tl-tr')
|
||||||
cls: 'ppm-toolbar shifted-right',
|
|
||||||
menuAlign: 'tl-tr',
|
|
||||||
items : [
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.unicodeText,
|
|
||||||
iconCls : 'menu__icon unicode',
|
|
||||||
checkable : true,
|
|
||||||
checkmark : false,
|
|
||||||
checked : false,
|
|
||||||
toggleGroup : 'popupparaeqinput',
|
|
||||||
type : 'input',
|
|
||||||
value : Asc.c_oAscMathInputType.Unicode
|
|
||||||
}),
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.latexText,
|
|
||||||
iconCls : 'menu__icon latex',
|
|
||||||
checkable : true,
|
|
||||||
checkmark : false,
|
|
||||||
checked : false,
|
|
||||||
toggleGroup : 'popupparaeqinput',
|
|
||||||
type : 'input',
|
|
||||||
value : Asc.c_oAscMathInputType.LaTeX
|
|
||||||
}),
|
|
||||||
{ caption : '--' },
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.currProfText,
|
|
||||||
iconCls : 'menu__icon professional-equation',
|
|
||||||
type : 'view',
|
|
||||||
value : {all: false, linear: false}
|
|
||||||
}),
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.currLinearText,
|
|
||||||
iconCls : 'menu__icon linear-equation',
|
|
||||||
type : 'view',
|
|
||||||
value : {all: false, linear: true}
|
|
||||||
}),
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.allProfText,
|
|
||||||
iconCls : 'menu__icon professional-equation',
|
|
||||||
type : 'view',
|
|
||||||
value : {all: true, linear: false}
|
|
||||||
}),
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.allLinearText,
|
|
||||||
iconCls : 'menu__icon linear-equation',
|
|
||||||
type : 'view',
|
|
||||||
value : {all: true, linear: true}
|
|
||||||
}),
|
|
||||||
{ caption : '--' },
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.eqToInlineText,
|
|
||||||
checkable : true,
|
|
||||||
checked : false,
|
|
||||||
type : 'mode'
|
|
||||||
})
|
|
||||||
]
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
me.menuTableSelectText = new Common.UI.MenuItem({
|
me.menuTableSelectText = new Common.UI.MenuItem({
|
||||||
|
@ -1658,66 +1601,8 @@ define([
|
||||||
|
|
||||||
me.menuParagraphEquation = new Common.UI.MenuItem({
|
me.menuParagraphEquation = new Common.UI.MenuItem({
|
||||||
caption : me.advancedEquationText,
|
caption : me.advancedEquationText,
|
||||||
menu : new Common.UI.Menu({
|
menu : me.createEquationMenu('popupparaeqinput', 'tl-tr')
|
||||||
cls: 'ppm-toolbar shifted-right',
|
|
||||||
menuAlign: 'tl-tr',
|
|
||||||
items : [
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.unicodeText,
|
|
||||||
iconCls : 'menu__icon unicode',
|
|
||||||
checkable : true,
|
|
||||||
checkmark : false,
|
|
||||||
checked : false,
|
|
||||||
toggleGroup : 'popupparaeqinput',
|
|
||||||
type : 'input',
|
|
||||||
value : Asc.c_oAscMathInputType.Unicode
|
|
||||||
}),
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.latexText,
|
|
||||||
iconCls : 'menu__icon latex',
|
|
||||||
checkable : true,
|
|
||||||
checkmark : false,
|
|
||||||
checked : false,
|
|
||||||
toggleGroup : 'popupparaeqinput',
|
|
||||||
type : 'input',
|
|
||||||
value : Asc.c_oAscMathInputType.LaTeX
|
|
||||||
}),
|
|
||||||
{ caption : '--' },
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.currProfText,
|
|
||||||
iconCls : 'menu__icon professional-equation',
|
|
||||||
type : 'view',
|
|
||||||
value : {all: false, linear: false}
|
|
||||||
}),
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.currLinearText,
|
|
||||||
iconCls : 'menu__icon linear-equation',
|
|
||||||
type : 'view',
|
|
||||||
value : {all: false, linear: true}
|
|
||||||
}),
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.allProfText,
|
|
||||||
iconCls : 'menu__icon professional-equation',
|
|
||||||
type : 'view',
|
|
||||||
value : {all: true, linear: false}
|
|
||||||
}),
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.allLinearText,
|
|
||||||
iconCls : 'menu__icon linear-equation',
|
|
||||||
type : 'view',
|
|
||||||
value : {all: true, linear: true}
|
|
||||||
}),
|
|
||||||
{ caption : '--' },
|
|
||||||
new Common.UI.MenuItem({
|
|
||||||
caption : me.eqToInlineText,
|
|
||||||
checkable : true,
|
|
||||||
checked : false,
|
|
||||||
type : 'mode'
|
|
||||||
})
|
|
||||||
]
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/** coauthoring begin **/
|
/** coauthoring begin **/
|
||||||
var menuCommentSeparatorPara = new Common.UI.MenuItem({
|
var menuCommentSeparatorPara = new Common.UI.MenuItem({
|
||||||
caption : '--'
|
caption : '--'
|
||||||
|
@ -2978,6 +2863,67 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
createEquationMenu: function(toggleGroup, menuAlign) {
|
||||||
|
return new Common.UI.Menu({
|
||||||
|
cls: 'ppm-toolbar shifted-right',
|
||||||
|
menuAlign: menuAlign,
|
||||||
|
items : [
|
||||||
|
new Common.UI.MenuItem({
|
||||||
|
caption : this.unicodeText,
|
||||||
|
iconCls : 'menu__icon unicode',
|
||||||
|
checkable : true,
|
||||||
|
checkmark : false,
|
||||||
|
checked : false,
|
||||||
|
toggleGroup : toggleGroup,
|
||||||
|
type : 'input',
|
||||||
|
value : Asc.c_oAscMathInputType.Unicode
|
||||||
|
}),
|
||||||
|
new Common.UI.MenuItem({
|
||||||
|
caption : this.latexText,
|
||||||
|
iconCls : 'menu__icon latex',
|
||||||
|
checkable : true,
|
||||||
|
checkmark : false,
|
||||||
|
checked : false,
|
||||||
|
toggleGroup : toggleGroup,
|
||||||
|
type : 'input',
|
||||||
|
value : Asc.c_oAscMathInputType.LaTeX
|
||||||
|
}),
|
||||||
|
{ caption : '--' },
|
||||||
|
new Common.UI.MenuItem({
|
||||||
|
caption : this.currProfText,
|
||||||
|
iconCls : 'menu__icon professional-equation',
|
||||||
|
type : 'view',
|
||||||
|
value : {all: false, linear: false}
|
||||||
|
}),
|
||||||
|
new Common.UI.MenuItem({
|
||||||
|
caption : this.currLinearText,
|
||||||
|
iconCls : 'menu__icon linear-equation',
|
||||||
|
type : 'view',
|
||||||
|
value : {all: false, linear: true}
|
||||||
|
}),
|
||||||
|
new Common.UI.MenuItem({
|
||||||
|
caption : this.allProfText,
|
||||||
|
iconCls : 'menu__icon professional-equation',
|
||||||
|
type : 'view',
|
||||||
|
value : {all: true, linear: false}
|
||||||
|
}),
|
||||||
|
new Common.UI.MenuItem({
|
||||||
|
caption : this.allLinearText,
|
||||||
|
iconCls : 'menu__icon linear-equation',
|
||||||
|
type : 'view',
|
||||||
|
value : {all: true, linear: true}
|
||||||
|
}),
|
||||||
|
{ caption : '--' },
|
||||||
|
new Common.UI.MenuItem({
|
||||||
|
caption : this.eqToInlineText,
|
||||||
|
checkable : true,
|
||||||
|
checked : false,
|
||||||
|
type : 'mode'
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
focus: function() {
|
focus: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
_.defer(function(){ me.cmpEl.focus(); }, 50);
|
_.defer(function(){ me.cmpEl.focus(); }, 50);
|
||||||
|
|
|
@ -174,7 +174,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#equation-container {
|
#equation-container {
|
||||||
padding: 2px;
|
padding: 4px;
|
||||||
|
.separator {
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-menu.list-settings-level {
|
.dropdown-menu.list-settings-level {
|
||||||
|
|
Loading…
Reference in a new issue