Menu component: added clearAll method.

This commit is contained in:
Julia Radzhabova 2017-11-13 11:41:32 +03:00
parent e17fa5ffea
commit d598aed90d
4 changed files with 17 additions and 30 deletions

View file

@ -595,7 +595,15 @@ define([
this.options.additionalAlign.call(this, menuRoot, left, top);
else
menuRoot.css({left: left, top: top});
},
clearAll: function() {
_.each(this.items, function(item){
if (item.setChecked)
item.setChecked(false, true);
});
}
}), {
Manager: (function() {
return manager;

View file

@ -517,7 +517,7 @@ define([
if (!(index < 0)) {
this.toolbar.btnHorizontalAlign.menu.items[index].setChecked(true);
} else if (index == -255) {
this._clearChecked(this.toolbar.btnHorizontalAlign.menu);
this.toolbar.btnHorizontalAlign.menu.clearAll();
}
var btnHorizontalAlign = this.toolbar.btnHorizontalAlign;
@ -587,7 +587,7 @@ define([
Math.abs(this._state.pgsize[1] - h) > 0.01) {
this._state.pgsize = [w, h];
if (this.toolbar.mnuPageSize) {
this._clearChecked(this.toolbar.mnuPageSize);
this.toolbar.mnuPageSize.clearAll();
_.each(this.toolbar.mnuPageSize.items, function(item){
if (item.value && typeof(item.value) == 'object' &&
Math.abs(item.value[0] - width) < 0.01 && Math.abs(item.value[1] - height) < 0.01) {
@ -611,7 +611,7 @@ define([
Math.abs(this._state.pgmargins[3] - right) > 0.01) {
this._state.pgmargins = [top, left, bottom, right];
if (this.toolbar.btnPageMargins.menu) {
this._clearChecked(this.toolbar.btnPageMargins.menu);
this.toolbar.btnPageMargins.menu.clearAll();
_.each(this.toolbar.btnPageMargins.menu.items, function(item){
if (item.value && typeof(item.value) == 'object' &&
Math.abs(item.value[0] - top) < 0.01 && Math.abs(item.value[1] - left) < 0.01 &&
@ -1607,7 +1607,7 @@ define([
case Asc.c_oAscDropCap.Margin: index = 2; break;
}
if (index < 0)
this._clearChecked(this.toolbar.btnDropCap.menu);
this.toolbar.btnDropCap.menu.clearAll();
else
this.toolbar.btnDropCap.menu.items[index].setChecked(true);
@ -1740,7 +1740,7 @@ define([
return;
if (index < 0)
this._clearChecked(this.toolbar.btnColumns.menu);
this.toolbar.btnColumns.menu.clearAll();
else
this.toolbar.btnColumns.menu.items[index].setChecked(true);
this._state.columns = index;
@ -2658,13 +2658,6 @@ define([
this._state.clrshd_asccolor = undefined;
},
_clearChecked: function(menu) {
_.each(menu.items, function(item){
if (item.setChecked)
item.setChecked(false, true);
});
},
_onInitEditorStyles: function(styles) {
window.styles_loaded = false;

View file

@ -502,7 +502,7 @@ define([
if (!(index < 0)) {
btnHorizontalAlign.menu.items[index].setChecked(true);
} else if (index == -255) {
this._clearChecked(btnHorizontalAlign.menu);
btnHorizontalAlign.menu.clearAll();
}
if (btnHorizontalAlign.rendered) {
@ -535,7 +535,7 @@ define([
if (!(index < 0)) {
btnVerticalAlign.menu.items[index].setChecked(true);
} else if (index == -255) {
this._clearChecked(btnVerticalAlign.menu);
btnVerticalAlign.menu.clearAll();
}
if (btnVerticalAlign.rendered) {
@ -1950,13 +1950,6 @@ define([
this._state.clrtext_asccolor = undefined;
},
_clearChecked: function(menu) {
_.each(menu.items, function(item){
if (item.setChecked)
item.setChecked(false, true);
});
},
_onInitEditorThemes: function(editorThemes, documentThemes) {
var me = this;
window.styles_loaded = false;

View file

@ -1936,7 +1936,7 @@ define([
toolbar.btnAlignCenter.toggle(false, true);
toolbar.btnAlignJust.toggle(false, true);
this._clearChecked(toolbar.btnHorizontalAlign.menu);
toolbar.btnHorizontalAlign.menu.clearAll();
}
var btnHorizontalAlign = this.toolbar.btnHorizontalAlign;
@ -2075,7 +2075,7 @@ define([
} else
val = info.asc_getAngle();
if (this._state.angle !== val) {
this._clearChecked(toolbar.btnTextOrient.menu);
toolbar.btnTextOrient.menu.clearAll();
switch(val) {
case 45: toolbar.btnTextOrient.menu.items[1].setChecked(true, true); break;
case -45: toolbar.btnTextOrient.menu.items[2].setChecked(true, true); break;
@ -2753,13 +2753,6 @@ define([
return cellInfo ? cellInfo.asc_getFont().asc_getSize() : 12;
},
_clearChecked: function(menu) {
_.each(menu.items, function(item){
if (item.setChecked)
item.setChecked(false, true);
});
},
_setTableFormat: function(fmtname) {
var me = this;