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

View file

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

View file

@ -232,19 +232,32 @@ define([
initTextFormat: function () {
var me = this,
$pageTextFormat = $('.page[data-page=edit-text-format]'),
hAlign = _cellInfo.asc_getHorAlign() || 'left',
vAlign = _cellInfo.asc_getVertAlign() || 'bottom',
hAlign = _cellInfo.asc_getHorAlign(),
vAlign = _cellInfo.asc_getVertAlign(),
hAlignStr = 'left',
vAlignStr = 'bottom',
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) {
var $radioHAlign = $pageTextFormat.find('input:radio[name=text-halign]'),
$radioVAlign = $pageTextFormat.find('input:radio[name=text-valign]'),
$switchWrapText = $pageTextFormat.find('#edit-cell-wrap-text input');
$radioHAlign.val([hAlign]);
$radioVAlign.val([vAlign]);
$radioHAlign.val([hAlignStr]);
$radioVAlign.val([vAlignStr]);
$switchWrapText.prop('checked', isWrapText);
$radioHAlign.single('change', _.bind(me.onHAlignChange, me));
@ -419,14 +432,29 @@ define([
onHAlignChange: function (e) {
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);
},
onVAlignChange: function (e) {
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);
},

View file

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