[SSE] Changed using asc_setCellVertAlign, asc_setCellAlign functions.

This commit is contained in:
Julia Radzhabova 2017-08-24 14:22:59 +03:00
parent 13b623ef0c
commit 9efa672947
4 changed files with 96 additions and 53 deletions

View file

@ -254,17 +254,17 @@ define([
toolbar.mnuBorderWidth.on('item:toggle', _.bind(this.onBordersWidth, this)); toolbar.mnuBorderWidth.on('item:toggle', _.bind(this.onBordersWidth, this));
toolbar.mnuBorderColorPicker.on('select', _.bind(this.onBordersColor, this)); toolbar.mnuBorderColorPicker.on('select', _.bind(this.onBordersColor, this));
} }
toolbar.btnAlignLeft.on('click', _.bind(this.onHorizontalAlign, this, 'left')); toolbar.btnAlignLeft.on('click', _.bind(this.onHorizontalAlign, this, AscCommon.align_Left));
toolbar.btnAlignCenter.on('click', _.bind(this.onHorizontalAlign, this, 'center')); toolbar.btnAlignCenter.on('click', _.bind(this.onHorizontalAlign, this, AscCommon.align_Center));
toolbar.btnAlignRight.on('click', _.bind(this.onHorizontalAlign, this, 'right')); toolbar.btnAlignRight.on('click', _.bind(this.onHorizontalAlign, this, AscCommon.align_Right));
toolbar.btnAlignJust.on('click', _.bind(this.onHorizontalAlign, this, 'justify')); toolbar.btnAlignJust.on('click', _.bind(this.onHorizontalAlign, this, AscCommon.align_Justify));
toolbar.btnHorizontalAlign.menu.on('item:click', _.bind(this.onHorizontalAlignMenu, this)); toolbar.btnHorizontalAlign.menu.on('item:click', _.bind(this.onHorizontalAlignMenu, this));
toolbar.btnVerticalAlign.menu.on('item:click', _.bind(this.onVerticalAlignMenu, this)); toolbar.btnVerticalAlign.menu.on('item:click', _.bind(this.onVerticalAlignMenu, this));
toolbar.btnMerge.on('click', _.bind(this.onMergeCellsMenu, this, toolbar.btnMerge.menu, toolbar.btnMerge.menu.items[0])); toolbar.btnMerge.on('click', _.bind(this.onMergeCellsMenu, this, toolbar.btnMerge.menu, toolbar.btnMerge.menu.items[0]));
toolbar.btnMerge.menu.on('item:click', _.bind(this.onMergeCellsMenu, this)); toolbar.btnMerge.menu.on('item:click', _.bind(this.onMergeCellsMenu, this));
toolbar.btnAlignTop.on('click', _.bind(this.onVerticalAlign, this, 'top')); toolbar.btnAlignTop.on('click', _.bind(this.onVerticalAlign, this, Asc.c_oAscVAlign.Top));
toolbar.btnAlignMiddle.on('click', _.bind(this.onVerticalAlign, this, 'center')); toolbar.btnAlignMiddle.on('click', _.bind(this.onVerticalAlign, this, Asc.c_oAscVAlign.Center));
toolbar.btnAlignBottom.on('click', _.bind(this.onVerticalAlign, this, 'bottom')); toolbar.btnAlignBottom.on('click', _.bind(this.onVerticalAlign, this, Asc.c_oAscVAlign.Bottom));
toolbar.btnWrap.on('click', _.bind(this.onWrap, this)); toolbar.btnWrap.on('click', _.bind(this.onWrap, this));
toolbar.btnTextOrient.menu.on('item:click', _.bind(this.onTextOrientationMenu, this)); toolbar.btnTextOrient.menu.on('item:click', _.bind(this.onTextOrientationMenu, this));
toolbar.btnInsertImage.menu.on('item:click', _.bind(this.onInsertImageMenu, this)); toolbar.btnInsertImage.menu.on('item:click', _.bind(this.onInsertImageMenu, this));
@ -602,8 +602,8 @@ define([
onHorizontalAlign: function(type, btn, e) { onHorizontalAlign: function(type, btn, e) {
this._state.pralign = undefined; this._state.pralign = undefined;
if (this.api) { if (this.api) {
this.api.asc_setCellAlign(!btn.pressed ? 'none' : type); this.api.asc_setCellAlign(!btn.pressed ? null : type);
this.toolbar.btnWrap.allowDepress = !(type == 'justify'); this.toolbar.btnWrap.allowDepress = !(type == AscCommon.align_Justify);
} }
Common.NotificationCenter.trigger('edit:complete', this.toolbar); Common.NotificationCenter.trigger('edit:complete', this.toolbar);
@ -622,9 +622,9 @@ define([
this._state.pralign = undefined; this._state.pralign = undefined;
if (this.api) if (this.api)
this.api.asc_setCellAlign(!item.checked ? 'none' : item.value); this.api.asc_setCellAlign(!item.checked ? null : item.value);
this.toolbar.btnWrap.allowDepress = !(item.value == 'justify'); this.toolbar.btnWrap.allowDepress = !(item.value == AscCommon.align_Justify);
Common.NotificationCenter.trigger('edit:complete', this.toolbar); Common.NotificationCenter.trigger('edit:complete', this.toolbar);
Common.component.Analytics.trackEvent('ToolBar', 'Horizontal Align'); Common.component.Analytics.trackEvent('ToolBar', 'Horizontal Align');
@ -642,7 +642,7 @@ define([
this._state.valign = undefined; this._state.valign = undefined;
if (this.api) if (this.api)
this.api.asc_setCellVertAlign(!item.checked ? 'bottom' : item.value); this.api.asc_setCellVertAlign(!item.checked ? Asc.c_oAscVAlign.Bottom : item.value);
Common.NotificationCenter.trigger('edit:complete', this.toolbar); Common.NotificationCenter.trigger('edit:complete', this.toolbar);
Common.component.Analytics.trackEvent('ToolBar', 'Vertical Align'); Common.component.Analytics.trackEvent('ToolBar', 'Vertical Align');
@ -651,7 +651,7 @@ define([
onVerticalAlign: function(type, btn, e) { onVerticalAlign: function(type, btn, e) {
this._state.valign = undefined; this._state.valign = undefined;
if (this.api) { if (this.api) {
this.api.asc_setCellVertAlign(!btn.pressed ? 'bottom' : type); this.api.asc_setCellVertAlign(!btn.pressed ? Asc.c_oAscVAlign.Bottom : type);
} }
Common.NotificationCenter.trigger('edit:complete', this.toolbar); Common.NotificationCenter.trigger('edit:complete', this.toolbar);
@ -1906,10 +1906,10 @@ define([
var index = -1, align; var index = -1, align;
switch (fontparam) { switch (fontparam) {
case 'left': index = 0; align = 'btn-align-left'; break; case AscCommon.align_Left: index = 0; align = 'btn-align-left'; break;
case 'center': index = 1; align = 'btn-align-center'; break; case AscCommon.align_Center: index = 1; align = 'btn-align-center'; break;
case 'right': index = 2; align = 'btn-align-right'; break; case AscCommon.align_Right: index = 2; align = 'btn-align-right'; break;
case 'justify': index = 3; align = 'btn-align-just'; break; case AscCommon.align_Justify: index = 3; align = 'btn-align-just'; break;
default: index = -255; align = 'btn-align-left'; break; default: index = -255; align = 'btn-align-left'; break;
} }
if (!(index < 0)) { if (!(index < 0)) {
@ -1939,7 +1939,7 @@ define([
} }
} }
need_disable = (fontparam == 'justify' || selectionType == Asc.c_oAscSelectionType.RangeShapeText); need_disable = (fontparam == AscCommon.align_Justify || selectionType == Asc.c_oAscSelectionType.RangeShapeText);
toolbar.btnTextOrient.menu.items[1].setDisabled(need_disable); toolbar.btnTextOrient.menu.items[1].setDisabled(need_disable);
toolbar.btnTextOrient.menu.items[2].setDisabled(need_disable); toolbar.btnTextOrient.menu.items[2].setDisabled(need_disable);
@ -1951,9 +1951,9 @@ define([
index = -1; align = ''; index = -1; align = '';
switch (fontparam) { switch (fontparam) {
case 'top': index = 0; align = 'btn-valign-top'; break; case Asc.c_oAscVAlign.Top: index = 0; align = 'btn-valign-top'; break;
case 'center': index = 1; align = 'btn-valign-middle'; break; case Asc.c_oAscVAlign.Center: index = 1; align = 'btn-valign-middle'; break;
case 'bottom': index = 2; align = 'btn-valign-bottom'; break; case Asc.c_oAscVAlign.Bottom: index = 2; align = 'btn-valign-bottom'; break;
} }
if (index > -1) { if (index > -1) {

View file

@ -1072,7 +1072,7 @@ define([
allowDepress: true, allowDepress: true,
toggleGroup : 'halignGroup', toggleGroup : 'halignGroup',
checked : true, checked : true,
value : 'left' value : AscCommon.align_Left
}, },
{ {
caption : me.tipAlignCenter, caption : me.tipAlignCenter,
@ -1081,7 +1081,7 @@ define([
checkable : true, checkable : true,
allowDepress: true, allowDepress: true,
toggleGroup : 'halignGroup', toggleGroup : 'halignGroup',
value : 'center' value : AscCommon.align_Center
}, },
{ {
caption : me.tipAlignRight, caption : me.tipAlignRight,
@ -1090,7 +1090,7 @@ define([
checkable : true, checkable : true,
allowDepress: true, allowDepress: true,
toggleGroup : 'halignGroup', toggleGroup : 'halignGroup',
value : 'right' value : AscCommon.align_Right
}, },
{ {
caption : me.tipAlignJust, caption : me.tipAlignJust,
@ -1099,7 +1099,7 @@ define([
checkable : true, checkable : true,
allowDepress: true, allowDepress: true,
toggleGroup : 'halignGroup', toggleGroup : 'halignGroup',
value : 'justify' value : AscCommon.align_Justify
} }
] ]
}) })
@ -1120,7 +1120,7 @@ define([
checkable : true, checkable : true,
allowDepress: true, allowDepress: true,
toggleGroup : 'valignGroup', toggleGroup : 'valignGroup',
value : 'top' value : Asc.c_oAscVAlign.Top
}, },
{ {
caption : me.tipAlignMiddle, caption : me.tipAlignMiddle,
@ -1129,7 +1129,7 @@ define([
checkable : true, checkable : true,
allowDepress: true, allowDepress: true,
toggleGroup : 'valignGroup', toggleGroup : 'valignGroup',
value : 'center' value : Asc.c_oAscVAlign.Center
}, },
{ {
caption : me.tipAlignBottom, caption : me.tipAlignBottom,
@ -1139,7 +1139,7 @@ define([
allowDepress: true, allowDepress: true,
checked : true, checked : true,
toggleGroup : 'valignGroup', toggleGroup : 'valignGroup',
value : 'bottom' value : Asc.c_oAscVAlign.Bottom
} }
] ]
}) })

View file

@ -232,19 +232,32 @@ define([
initTextFormat: function () { initTextFormat: function () {
var me = this, var me = this,
$pageTextFormat = $('.page[data-page=edit-text-format]'), $pageTextFormat = $('.page[data-page=edit-text-format]'),
hAlign = _cellInfo.asc_getHorAlign() || 'left', hAlign = _cellInfo.asc_getHorAlign(),
vAlign = _cellInfo.asc_getVertAlign() || 'bottom', vAlign = _cellInfo.asc_getVertAlign(),
hAlignStr = 'left',
vAlignStr = 'bottom',
isWrapText = _cellInfo.asc_getFlags().asc_getWrapText(); isWrapText = _cellInfo.asc_getFlags().asc_getWrapText();
$('#text-format .item-media i').removeClass().addClass(Common.Utils.String.format('icon icon-text-align-{0}', hAlign == 'none' ? 'left' : hAlign)); if (vAlign == Asc.c_oAscVAlign.Top)
vAlignStr = 'top';
else if (vAlign == Asc.c_oAscVAlign.Center)
vAlignStr = 'center';
switch (hAlign) {
case AscCommon.align_Center: hAlignStr = 'center'; break;
case AscCommon.align_Right: hAlignStr = 'right'; break;
case AscCommon.align_Justify: hAlignStr = 'justify'; break;
}
$('#text-format .item-media i').removeClass().addClass(Common.Utils.String.format('icon icon-text-align-{0}', hAlignStr));
if ($pageTextFormat.length > 0) { if ($pageTextFormat.length > 0) {
var $radioHAlign = $pageTextFormat.find('input:radio[name=text-halign]'), var $radioHAlign = $pageTextFormat.find('input:radio[name=text-halign]'),
$radioVAlign = $pageTextFormat.find('input:radio[name=text-valign]'), $radioVAlign = $pageTextFormat.find('input:radio[name=text-valign]'),
$switchWrapText = $pageTextFormat.find('#edit-cell-wrap-text input'); $switchWrapText = $pageTextFormat.find('#edit-cell-wrap-text input');
$radioHAlign.val([hAlign]); $radioHAlign.val([hAlignStr]);
$radioVAlign.val([vAlign]); $radioVAlign.val([vAlignStr]);
$switchWrapText.prop('checked', isWrapText); $switchWrapText.prop('checked', isWrapText);
$radioHAlign.single('change', _.bind(me.onHAlignChange, me)); $radioHAlign.single('change', _.bind(me.onHAlignChange, me));
@ -419,14 +432,29 @@ define([
onHAlignChange: function (e) { onHAlignChange: function (e) {
var $target = $(e.currentTarget), var $target = $(e.currentTarget),
type = $target.prop('value'); value = $target.prop('value'),
type = AscCommon.align_Left;
if (value == 'center')
type = AscCommon.align_Center;
else if (value == 'right')
type = AscCommon.align_Right;
else if (value == 'justify')
type = AscCommon.align_Justify;
this.api.asc_setCellAlign(type); this.api.asc_setCellAlign(type);
}, },
onVAlignChange: function (e) { onVAlignChange: function (e) {
var $target = $(e.currentTarget), var $target = $(e.currentTarget),
type = $target.prop('value'); value = $target.prop('value'),
type = Asc.c_oAscVAlign.Bottom;
if (value == 'top') {
type = Asc.c_oAscVAlign.Top;
} else if (value == 'center') {
type = Asc.c_oAscVAlign.Center;
}
this.api.asc_setCellVertAlign(type); this.api.asc_setCellVertAlign(type);
}, },

View file

@ -156,28 +156,28 @@ define([
// Align // Align
$('#edit-text-align-block').css('display', (_textIn == TextType.inShape) ? 'block' : 'none'); $('#edit-text-align-block').css('display', (_textIn == TextType.inShape) ? 'block' : 'none');
var hAlign = _cellInfo.asc_getHorAlign() || 'left', var hAlign = _cellInfo.asc_getHorAlign(),
vAlign = _cellInfo.asc_getVertAlign() || 'bottom'; vAlign = _cellInfo.asc_getVertAlign();
$('#font-left').toggleClass('active', hAlign==='left'); $('#font-left').toggleClass('active', hAlign===AscCommon.align_Left);
$('#font-center').toggleClass('active', hAlign==='center'); $('#font-center').toggleClass('active', hAlign===AscCommon.align_Center);
$('#font-right').toggleClass('active', hAlign==='right'); $('#font-right').toggleClass('active', hAlign===AscCommon.align_Right);
$('#font-just').toggleClass('active', hAlign==='justify'); $('#font-just').toggleClass('active', hAlign===AscCommon.align_Justify);
$('#font-top').toggleClass('active', vAlign==='top'); $('#font-top').toggleClass('active', vAlign===Asc.c_oAscVAlign.Top);
$('#font-middle').toggleClass('active', vAlign==='center'); $('#font-middle').toggleClass('active', vAlign===Asc.c_oAscVAlign.Center);
$('#font-bottom').toggleClass('active', vAlign==='bottom'); $('#font-bottom').toggleClass('active', vAlign===Asc.c_oAscVAlign.Bottom);
// Handlers // Handlers
$('#font-bold').single('click', _.bind(me.onBold, me)); $('#font-bold').single('click', _.bind(me.onBold, me));
$('#font-italic').single('click', _.bind(me.onItalic, me)); $('#font-italic').single('click', _.bind(me.onItalic, me));
$('#font-underline').single('click', _.bind(me.onUnderline, me)); $('#font-underline').single('click', _.bind(me.onUnderline, me));
$('#font-left').single('click', _.bind(me.onHAlign, me, 'left')); $('#font-left').single('click', _.bind(me.onHAlign, me, AscCommon.align_Left));
$('#font-center').single('click', _.bind(me.onHAlign, me, 'center')); $('#font-center').single('click', _.bind(me.onHAlign, me, AscCommon.align_Center));
$('#font-right').single('click', _.bind(me.onHAlign, me, 'right')); $('#font-right').single('click', _.bind(me.onHAlign, me, AscCommon.align_Right));
$('#font-just').single('click', _.bind(me.onHAlign, me, 'justify')); $('#font-just').single('click', _.bind(me.onHAlign, me, AscCommon.align_Justify));
$('#font-top').single('click', _.bind(me.onVAlign, me, 'top')); $('#font-top').single('click', _.bind(me.onVAlign, me, Asc.c_oAscVAlign.Top));
$('#font-middle').single('click', _.bind(me.onVAlign, me, 'center')); $('#font-middle').single('click', _.bind(me.onVAlign, me, Asc.c_oAscVAlign.Center));
$('#font-bottom').single('click', _.bind(me.onVAlign, me, 'bottom')); $('#font-bottom').single('click', _.bind(me.onVAlign, me, Asc.c_oAscVAlign.Bottom));
}, },
initFontsPage: function () { initFontsPage: function () {
@ -283,14 +283,29 @@ define([
onHAlignChange: function (e) { onHAlignChange: function (e) {
var $target = $(e.currentTarget), var $target = $(e.currentTarget),
type = $target.prop('value'); value = $target.prop('value'),
type = AscCommon.align_Left;
if (value == 'center')
type = AscCommon.align_Center;
else if (value == 'right')
type = AscCommon.align_Right;
else if (value == 'justify')
type = AscCommon.align_Justify;
this.api.asc_setCellAlign(type); this.api.asc_setCellAlign(type);
}, },
onVAlignChange: function (e) { onVAlignChange: function (e) {
var $target = $(e.currentTarget), var $target = $(e.currentTarget),
type = $target.prop('value'); value = $target.prop('value'),
type = Asc.c_oAscVAlign.Bottom;
if (value == 'top') {
type = Asc.c_oAscVAlign.Top;
} else if (value == 'center') {
type = Asc.c_oAscVAlign.Center;
}
this.api.asc_setCellVertAlign(type); this.api.asc_setCellVertAlign(type);
}, },