[Common] refactoring. defined $icon element for a button
This commit is contained in:
parent
fc6c6c2cb8
commit
6d0a353d78
|
@ -350,6 +350,7 @@ define([
|
||||||
me.menu.render(me.cmpEl);
|
me.menu.render(me.cmpEl);
|
||||||
|
|
||||||
parentEl.html(me.cmpEl);
|
parentEl.html(me.cmpEl);
|
||||||
|
me.$icon = me.$el.find('.icon');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1323,8 +1323,6 @@ define([
|
||||||
Array.prototype.push.apply(me.paragraphControls, me.btnsPageBreak);
|
Array.prototype.push.apply(me.paragraphControls, me.btnsPageBreak);
|
||||||
}.call(this);
|
}.call(this);
|
||||||
|
|
||||||
this.btnSave.$icon = $('.icon', this.btnSave.cmpEl);
|
|
||||||
this.btnHorizontalAlign.$icon = $('.icon', this.btnHorizontalAlign.cmpEl);
|
|
||||||
return $host;
|
return $host;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -514,14 +514,9 @@ define([
|
||||||
btnHorizontalAlign.menu.clearAll();
|
btnHorizontalAlign.menu.clearAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btnHorizontalAlign.rendered) {
|
if ( btnHorizontalAlign.rendered && btnHorizontalAlign.$icon ) {
|
||||||
var iconEl = $('.icon', btnHorizontalAlign.cmpEl);
|
btnHorizontalAlign.$icon.removeClass(btnHorizontalAlign.options.icls).addClass(align);
|
||||||
|
|
||||||
if (iconEl) {
|
|
||||||
iconEl.removeClass(btnHorizontalAlign.options.icls);
|
|
||||||
btnHorizontalAlign.options.icls = align;
|
btnHorizontalAlign.options.icls = align;
|
||||||
iconEl.addClass(btnHorizontalAlign.options.icls);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -547,14 +542,9 @@ define([
|
||||||
btnVerticalAlign.menu.clearAll();
|
btnVerticalAlign.menu.clearAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btnVerticalAlign.rendered) {
|
if ( btnVerticalAlign.rendered && btnVerticalAlign.$icon ) {
|
||||||
var iconEl = $('.icon', btnVerticalAlign.cmpEl);
|
btnVerticalAlign.$icon.removeClass(btnVerticalAlign.options.icls).addClass(align);
|
||||||
|
|
||||||
if (iconEl) {
|
|
||||||
iconEl.removeClass(btnVerticalAlign.options.icls);
|
|
||||||
btnVerticalAlign.options.icls = align;
|
btnVerticalAlign.options.icls = align;
|
||||||
iconEl.addClass(btnVerticalAlign.options.icls);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -912,7 +902,7 @@ define([
|
||||||
var toolbar = this.toolbar;
|
var toolbar = this.toolbar;
|
||||||
if (this.api && this.api.asc_isDocumentCanSave) {
|
if (this.api && this.api.asc_isDocumentCanSave) {
|
||||||
var isModified = this.api.asc_isDocumentCanSave();
|
var isModified = this.api.asc_isDocumentCanSave();
|
||||||
var isSyncButton = $('.icon', this.toolbar.btnSave.cmpEl).hasClass('btn-synch');
|
var isSyncButton = this.toolbar.btnSave.$icon.hasClass('btn-synch');
|
||||||
if (!isModified && !isSyncButton && !this.toolbar.mode.forcesave)
|
if (!isModified && !isSyncButton && !this.toolbar.mode.forcesave)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1046,14 +1036,11 @@ define([
|
||||||
|
|
||||||
onMenuHorizontalAlignSelect: function(menu, item) {
|
onMenuHorizontalAlignSelect: function(menu, item) {
|
||||||
this._state.pralign = undefined;
|
this._state.pralign = undefined;
|
||||||
var btnHorizontalAlign = this.toolbar.btnHorizontalAlign,
|
var btnHorizontalAlign = this.toolbar.btnHorizontalAlign;
|
||||||
iconEl = $('.icon', btnHorizontalAlign.cmpEl);
|
|
||||||
|
|
||||||
if (iconEl) {
|
btnHorizontalAlign.$icon.removeClass(btnHorizontalAlign.options.icls);
|
||||||
iconEl.removeClass(btnHorizontalAlign.options.icls);
|
|
||||||
btnHorizontalAlign.options.icls = !item.checked ? 'btn-align-left' : item.options.icls;
|
btnHorizontalAlign.options.icls = !item.checked ? 'btn-align-left' : item.options.icls;
|
||||||
iconEl.addClass(btnHorizontalAlign.options.icls);
|
btnHorizontalAlign.$icon.addClass(btnHorizontalAlign.options.icls);
|
||||||
}
|
|
||||||
|
|
||||||
if (this.api && item.checked)
|
if (this.api && item.checked)
|
||||||
this.api.put_PrAlign(item.value);
|
this.api.put_PrAlign(item.value);
|
||||||
|
@ -1063,14 +1050,11 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onMenuVerticalAlignSelect: function(menu, item) {
|
onMenuVerticalAlignSelect: function(menu, item) {
|
||||||
var btnVerticalAlign = this.toolbar.btnVerticalAlign,
|
var btnVerticalAlign = this.toolbar.btnVerticalAlign;
|
||||||
iconEl = $('.icon', btnVerticalAlign.cmpEl);
|
|
||||||
|
|
||||||
if (iconEl) {
|
btnVerticalAlign.$icon.removeClass(btnVerticalAlign.options.icls);
|
||||||
iconEl.removeClass(btnVerticalAlign.options.icls);
|
|
||||||
btnVerticalAlign.options.icls = !item.checked ? 'btn-align-middle' : item.options.icls;
|
btnVerticalAlign.options.icls = !item.checked ? 'btn-align-middle' : item.options.icls;
|
||||||
iconEl.addClass(btnVerticalAlign.options.icls);
|
btnVerticalAlign.$icon.addClass(btnVerticalAlign.options.icls);
|
||||||
}
|
|
||||||
|
|
||||||
this._state.vtextalign = undefined;
|
this._state.vtextalign = undefined;
|
||||||
if (this.api && item.checked)
|
if (this.api && item.checked)
|
||||||
|
|
|
@ -1012,8 +1012,6 @@ define([
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
me.btnSave.$icon = $('.icon', me.btnSave.cmpEl);
|
|
||||||
|
|
||||||
var created = me.btnsInsertImage.concat(me.btnsInsertText, me.btnsInsertShape, me.btnsAddSlide);
|
var created = me.btnsInsertImage.concat(me.btnsInsertText, me.btnsInsertShape, me.btnsAddSlide);
|
||||||
this.lockToolbar(PE.enumLock.disableOnStart, true, {array: created});
|
this.lockToolbar(PE.enumLock.disableOnStart, true, {array: created});
|
||||||
|
|
||||||
|
|
|
@ -495,8 +495,7 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onSubscriptMenu: function(menu, item) {
|
onSubscriptMenu: function(menu, item) {
|
||||||
var btnSubscript = this.toolbar.btnSubscript,
|
var btnSubscript = this.toolbar.btnSubscript;
|
||||||
iconEl = $('.icon', btnSubscript.cmpEl);
|
|
||||||
|
|
||||||
if (item.value == 'sub') {
|
if (item.value == 'sub') {
|
||||||
this._state.subscript = undefined;
|
this._state.subscript = undefined;
|
||||||
|
@ -506,9 +505,8 @@ define([
|
||||||
this.api.asc_setCellSuperscript(item.checked);
|
this.api.asc_setCellSuperscript(item.checked);
|
||||||
}
|
}
|
||||||
if (item.checked) {
|
if (item.checked) {
|
||||||
iconEl.removeClass(btnSubscript.options.icls);
|
btnSubscript.$icon.removeClass(btnSubscript.options.icls).addClass(item.options.icls);
|
||||||
btnSubscript.options.icls = item.options.icls;
|
btnSubscript.options.icls = item.options.icls;
|
||||||
iconEl.addClass(btnSubscript.options.icls);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
||||||
|
@ -613,13 +611,8 @@ define([
|
||||||
bordersColor = btnBorders.options.borderscolor;
|
bordersColor = btnBorders.options.borderscolor;
|
||||||
|
|
||||||
if ( btnBorders.rendered ) {
|
if ( btnBorders.rendered ) {
|
||||||
var iconEl = $('.icon', btnBorders.cmpEl);
|
btnBorders.$icon.removeClass(btnBorders.options.icls).addClass(item.options.icls);
|
||||||
|
|
||||||
if (iconEl) {
|
|
||||||
iconEl.removeClass(btnBorders.options.icls);
|
|
||||||
btnBorders.options.icls = item.options.icls;
|
btnBorders.options.icls = item.options.icls;
|
||||||
iconEl.addClass(btnBorders.options.icls);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
btnBorders.options.borderId = item.options.borderId;
|
btnBorders.options.borderId = item.options.borderId;
|
||||||
|
@ -681,14 +674,11 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onHorizontalAlignMenu: function(menu, item) {
|
onHorizontalAlignMenu: function(menu, item) {
|
||||||
var btnHorizontalAlign = this.toolbar.btnHorizontalAlign,
|
var btnHorizontalAlign = this.toolbar.btnHorizontalAlign;
|
||||||
iconEl = $('.icon', btnHorizontalAlign.cmpEl);
|
|
||||||
|
|
||||||
if (iconEl) {
|
btnHorizontalAlign.$icon.removeClass(btnHorizontalAlign.options.icls);
|
||||||
iconEl.removeClass(btnHorizontalAlign.options.icls);
|
|
||||||
btnHorizontalAlign.options.icls = !item.checked ? 'btn-align-left' : item.options.icls;
|
btnHorizontalAlign.options.icls = !item.checked ? 'btn-align-left' : item.options.icls;
|
||||||
iconEl.addClass(btnHorizontalAlign.options.icls);
|
btnHorizontalAlign.$icon.addClass(btnHorizontalAlign.options.icls);
|
||||||
}
|
|
||||||
|
|
||||||
this._state.pralign = undefined;
|
this._state.pralign = undefined;
|
||||||
if (this.api)
|
if (this.api)
|
||||||
|
@ -701,14 +691,11 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onVerticalAlignMenu: function(menu, item) {
|
onVerticalAlignMenu: function(menu, item) {
|
||||||
var btnVerticalAlign = this.toolbar.btnVerticalAlign,
|
var btnVerticalAlign = this.toolbar.btnVerticalAlign;
|
||||||
iconEl = $('.icon', btnVerticalAlign.cmpEl);
|
|
||||||
|
|
||||||
if (iconEl) {
|
btnVerticalAlign.$icon.removeClass(btnVerticalAlign.options.icls);
|
||||||
iconEl.removeClass(btnVerticalAlign.options.icls);
|
|
||||||
btnVerticalAlign.options.icls = !item.checked ? 'btn-valign-bottom' : item.options.icls;
|
btnVerticalAlign.options.icls = !item.checked ? 'btn-valign-bottom' : item.options.icls;
|
||||||
iconEl.addClass(btnVerticalAlign.options.icls);
|
btnVerticalAlign.$icon.addClass(btnVerticalAlign.options.icls);
|
||||||
}
|
|
||||||
|
|
||||||
this._state.valign = undefined;
|
this._state.valign = undefined;
|
||||||
if (this.api)
|
if (this.api)
|
||||||
|
@ -1792,13 +1779,10 @@ define([
|
||||||
btnSubscript.menu.clearAll();
|
btnSubscript.menu.clearAll();
|
||||||
} else {
|
} else {
|
||||||
btnSubscript.menu.items[index].setChecked(true);
|
btnSubscript.menu.items[index].setChecked(true);
|
||||||
if (btnSubscript.rendered) {
|
if ( btnSubscript.rendered && btnSubscript.$icon ) {
|
||||||
var iconEl = $('.icon', btnSubscript.cmpEl);
|
btnSubscript.$icon.removeClass(btnSubscript.options.icls);
|
||||||
if (iconEl) {
|
|
||||||
iconEl.removeClass(btnSubscript.options.icls);
|
|
||||||
btnSubscript.options.icls = btnSubscript.menu.items[index].options.icls;
|
btnSubscript.options.icls = btnSubscript.menu.items[index].options.icls;
|
||||||
iconEl.addClass(btnSubscript.options.icls);
|
btnSubscript.$icon.addClass(btnSubscript.options.icls);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1934,12 +1918,9 @@ define([
|
||||||
} else {
|
} else {
|
||||||
btnSubscript.menu.items[index].setChecked(true);
|
btnSubscript.menu.items[index].setChecked(true);
|
||||||
if ( btnSubscript.rendered ) {
|
if ( btnSubscript.rendered ) {
|
||||||
var iconEl = $('.icon', btnSubscript.cmpEl);
|
btnSubscript.$icon.removeClass(btnSubscript.options.icls);
|
||||||
if (iconEl) {
|
|
||||||
iconEl.removeClass(btnSubscript.options.icls);
|
|
||||||
btnSubscript.options.icls = btnSubscript.menu.items[index].options.icls;
|
btnSubscript.options.icls = btnSubscript.menu.items[index].options.icls;
|
||||||
iconEl.addClass(btnSubscript.options.icls);
|
btnSubscript.$icon.addClass(btnSubscript.options.icls);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2069,13 +2050,8 @@ define([
|
||||||
|
|
||||||
var btnHorizontalAlign = this.toolbar.btnHorizontalAlign;
|
var btnHorizontalAlign = this.toolbar.btnHorizontalAlign;
|
||||||
if ( btnHorizontalAlign.rendered ) {
|
if ( btnHorizontalAlign.rendered ) {
|
||||||
var hIconEl = $('.icon', btnHorizontalAlign.cmpEl);
|
btnHorizontalAlign.$icon.removeClass(btnHorizontalAlign.options.icls).addClass(align);
|
||||||
|
|
||||||
if (hIconEl) {
|
|
||||||
hIconEl.removeClass(btnHorizontalAlign.options.icls);
|
|
||||||
btnHorizontalAlign.options.icls = align;
|
btnHorizontalAlign.options.icls = align;
|
||||||
hIconEl.addClass(btnHorizontalAlign.options.icls);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2104,13 +2080,8 @@ define([
|
||||||
|
|
||||||
var btnVerticalAlign = this.toolbar.btnVerticalAlign;
|
var btnVerticalAlign = this.toolbar.btnVerticalAlign;
|
||||||
if ( btnVerticalAlign.rendered ) {
|
if ( btnVerticalAlign.rendered ) {
|
||||||
var vIconEl = $('.icon', btnVerticalAlign.cmpEl);
|
btnVerticalAlign.$icon.removeClass(btnVerticalAlign.options.icls).addClass(align);
|
||||||
|
|
||||||
if (vIconEl) {
|
|
||||||
vIconEl.removeClass(btnVerticalAlign.options.icls);
|
|
||||||
btnVerticalAlign.options.icls = align;
|
btnVerticalAlign.options.icls = align;
|
||||||
vIconEl.addClass(btnVerticalAlign.options.icls);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1388,7 +1388,6 @@ define([
|
||||||
// replacePlacholder('#id-toolbar-short-placeholder-btn-valign', this.btnVerticalAlign);
|
// replacePlacholder('#id-toolbar-short-placeholder-btn-valign', this.btnVerticalAlign);
|
||||||
// replacePlacholder('#id-toolbar-short-placeholder-btn-filter', this.btnAutofilter);
|
// replacePlacholder('#id-toolbar-short-placeholder-btn-filter', this.btnAutofilter);
|
||||||
|
|
||||||
this.btnSave.$icon = $('.icon', this.btnSave.cmpEl);
|
|
||||||
return $host;
|
return $host;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue