2016-12-07 13:05:50 +00:00
|
|
|
/*
|
|
|
|
*
|
2019-01-17 13:05:03 +00:00
|
|
|
* (c) Copyright Ascensio System SIA 2010-2019
|
2016-12-07 13:05:50 +00:00
|
|
|
*
|
|
|
|
* This program is a free software product. You can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
|
|
|
* version 3 as published by the Free Software Foundation. In accordance with
|
|
|
|
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
|
|
|
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
|
|
|
* of any third-party rights.
|
|
|
|
*
|
|
|
|
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
|
|
|
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
*
|
2019-01-17 13:00:34 +00:00
|
|
|
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
|
|
|
* street, Riga, Latvia, EU, LV-1050.
|
2016-12-07 13:05:50 +00:00
|
|
|
*
|
|
|
|
* The interactive user interfaces in modified source and object code versions
|
|
|
|
* of the Program must display Appropriate Legal Notices, as required under
|
|
|
|
* Section 5 of the GNU AGPL version 3.
|
|
|
|
*
|
|
|
|
* Pursuant to Section 7(b) of the License you must retain the original Product
|
|
|
|
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
|
|
|
* grant you any rights under trademark law for use of our trademarks.
|
|
|
|
*
|
|
|
|
* All the Product's GUI elements, including illustrations and icon sets, as
|
|
|
|
* well as technical writing content are licensed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
|
|
|
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* EditCell.js
|
|
|
|
* Spreadsheet Editor
|
|
|
|
*
|
|
|
|
* Created by Alexander Yuzhin on 12/6/16
|
2018-03-01 12:16:38 +00:00
|
|
|
* Copyright (c) 2018 Ascensio System SIA. All rights reserved.
|
2016-12-07 13:05:50 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
define([
|
|
|
|
'core',
|
|
|
|
'spreadsheeteditor/mobile/app/view/edit/EditCell',
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
|
|
|
'common/mobile/lib/component/ThemeColorPalette'
|
|
|
|
], function (core, view, $, _, Backbone) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
SSE.Controllers.EditCell = Backbone.Controller.extend(_.extend((function() {
|
|
|
|
var _fontsArray = [],
|
|
|
|
_stack = [],
|
2016-12-09 08:50:32 +00:00
|
|
|
_cellInfo = undefined,
|
|
|
|
_cellStyles = [],
|
|
|
|
_fontInfo = {},
|
2016-12-09 12:44:26 +00:00
|
|
|
_borderInfo = {color: '000000', width: 'medium'},
|
2016-12-14 14:14:00 +00:00
|
|
|
_styleSize = {width: 100, height: 50},
|
2016-12-09 08:50:32 +00:00
|
|
|
_isEdit = false;
|
2016-12-07 13:05:50 +00:00
|
|
|
|
|
|
|
function onApiLoadFonts(fonts, select) {
|
|
|
|
_.each(fonts, function(font){
|
|
|
|
var fontId = font.asc_getFontId();
|
|
|
|
_fontsArray.push({
|
|
|
|
id : fontId,
|
|
|
|
name : font.asc_getFontName(),
|
|
|
|
// displayValue: font.asc_getFontName(),
|
|
|
|
imgidx : font.asc_getFontThumbnail(),
|
|
|
|
type : font.asc_getFontType()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
Common.NotificationCenter.trigger('fonts:load', _fontsArray, select);
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
models: [],
|
|
|
|
collections: [],
|
|
|
|
views: [
|
|
|
|
'EditCell'
|
|
|
|
],
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
Common.NotificationCenter.on('editcontainer:show', _.bind(this.initEvents, this));
|
|
|
|
|
|
|
|
this.addListeners({
|
|
|
|
'EditCell': {
|
2016-12-14 14:14:00 +00:00
|
|
|
'page:show' : this.onPageShow,
|
|
|
|
'font:click' : this.onFontClick,
|
|
|
|
'style:click' : this.onStyleClick
|
2016-12-07 13:05:50 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
setApi: function (api) {
|
|
|
|
var me = this;
|
|
|
|
me.api = api;
|
|
|
|
|
2016-12-14 14:14:00 +00:00
|
|
|
me.api.asc_setThumbnailStylesSizes(_styleSize.width, _styleSize.height);
|
|
|
|
|
2016-12-09 08:50:32 +00:00
|
|
|
me.api.asc_registerCallback('asc_onInitEditorFonts', _.bind(onApiLoadFonts, me));
|
|
|
|
me.api.asc_registerCallback('asc_onSelectionChanged', _.bind(me.onApiSelectionChanged, me));
|
|
|
|
me.api.asc_registerCallback('asc_onEditorSelectionChanged', _.bind(me.onApiEditorSelectionChanged, me));
|
2017-01-19 11:12:23 +00:00
|
|
|
me.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(me.onApiInitEditorStyles, me));
|
2016-12-09 08:50:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setMode: function (mode) {
|
2017-05-25 09:55:29 +00:00
|
|
|
_isEdit = mode.isEdit;
|
2016-12-07 13:05:50 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onLaunch: function () {
|
|
|
|
this.createView('EditCell').render();
|
|
|
|
},
|
|
|
|
|
|
|
|
initEvents: function () {
|
2016-12-16 11:17:40 +00:00
|
|
|
if ($('#edit-cell').length < 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-12-07 13:05:50 +00:00
|
|
|
var me = this;
|
2016-12-09 08:50:32 +00:00
|
|
|
|
|
|
|
$('#font-bold').single('click', _.bind(me.onBold, me));
|
|
|
|
$('#font-italic').single('click', _.bind(me.onItalic, me));
|
|
|
|
$('#font-underline').single('click', _.bind(me.onUnderline, me));
|
|
|
|
|
|
|
|
me.getView('EditCell').renderStyles(_cellStyles);
|
2016-12-07 13:05:50 +00:00
|
|
|
|
|
|
|
me.initSettings();
|
|
|
|
},
|
|
|
|
|
2016-12-14 14:14:00 +00:00
|
|
|
|
|
|
|
|
2016-12-07 13:05:50 +00:00
|
|
|
onPageShow: function (view, pageId) {
|
|
|
|
var me = this;
|
|
|
|
|
|
|
|
me.initSettings(pageId);
|
|
|
|
},
|
|
|
|
|
|
|
|
initSettings: function (pageId) {
|
|
|
|
var me = this;
|
|
|
|
|
2016-12-09 08:50:32 +00:00
|
|
|
if ('#edit-text-fonts' == pageId) {
|
|
|
|
me.initFontsPage();
|
|
|
|
} else if ('#edit-text-color' == pageId) {
|
|
|
|
me.initTextColorPage();
|
|
|
|
} else if ('#edit-fill-color' == pageId) {
|
|
|
|
me.initFillColorPage();
|
2016-12-09 12:44:26 +00:00
|
|
|
} else if ('#edit-cell-border-color' == pageId) {
|
|
|
|
me.initBorderColorPage();
|
2016-12-09 08:50:32 +00:00
|
|
|
} else if ('#edit-text-format' == pageId) {
|
|
|
|
me.initTextFormat();
|
2016-12-09 12:44:26 +00:00
|
|
|
} else if ('#edit-border-style' == pageId) {
|
|
|
|
me.initBorderStyle();
|
2016-12-09 08:50:32 +00:00
|
|
|
} else if (!_.isUndefined(pageId) && pageId.indexOf('#edit-cell-format') > -1) {
|
|
|
|
me.initCellFormat();
|
|
|
|
} else {
|
|
|
|
me.initCellSettings(_cellInfo);
|
|
|
|
}
|
2016-12-07 13:05:50 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Public
|
|
|
|
|
|
|
|
getFonts: function() {
|
|
|
|
return _fontsArray;
|
|
|
|
},
|
|
|
|
|
|
|
|
getStack: function() {
|
|
|
|
return _stack;
|
|
|
|
},
|
|
|
|
|
|
|
|
getFontInfo: function () {
|
|
|
|
return _fontInfo;
|
|
|
|
},
|
|
|
|
|
|
|
|
getCell: function () {
|
2016-12-09 08:50:32 +00:00
|
|
|
return _cellInfo;
|
|
|
|
},
|
|
|
|
|
2016-12-14 14:14:00 +00:00
|
|
|
getStyleSize: function () {
|
|
|
|
return _styleSize;
|
|
|
|
},
|
|
|
|
|
2016-12-09 08:50:32 +00:00
|
|
|
initFontsPage: function () {
|
|
|
|
var me = this,
|
|
|
|
displaySize = _fontInfo.size;
|
|
|
|
|
|
|
|
_.isUndefined(displaySize) ? displaySize = this.textAuto : displaySize = displaySize + ' ' + this.textPt;
|
|
|
|
|
|
|
|
$('#font-size .item-after label').html(displaySize);
|
|
|
|
$('#font-size .button').single('click', _.bind(me.onFontSize, me));
|
|
|
|
},
|
|
|
|
|
|
|
|
initTextColorPage: function () {
|
|
|
|
var me = this,
|
|
|
|
palette = me.getView('EditCell').paletteTextColor,
|
|
|
|
color = me._sdkToThemeColor(_fontInfo.color);
|
|
|
|
|
|
|
|
if (palette) {
|
|
|
|
palette.select(color);
|
|
|
|
palette.on('select', _.bind(me.onTextColor, me));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
initFillColorPage: function () {
|
|
|
|
var me = this,
|
|
|
|
palette = me.getView('EditCell').paletteFillColor,
|
|
|
|
color = me._sdkToThemeColor(_cellInfo.asc_getFill().asc_getColor());
|
|
|
|
|
|
|
|
if (palette) {
|
|
|
|
palette.select(color);
|
|
|
|
palette.on('select', _.bind(me.onFillColor, me));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-12-09 12:44:26 +00:00
|
|
|
initBorderColorPage: function () {
|
|
|
|
var me = this,
|
|
|
|
palette = new Common.UI.ThemeColorPalette({
|
|
|
|
el: $('.page[data-page=edit-border-color] .page-content')
|
|
|
|
});
|
|
|
|
|
|
|
|
if (palette) {
|
|
|
|
palette.select(_borderInfo.color);
|
|
|
|
palette.on('select', _.bind(function (palette, color) {
|
|
|
|
_borderInfo.color = color;
|
|
|
|
$('#edit-border-color .color-preview').css('background-color', '#' + (_.isObject(_borderInfo.color) ? _borderInfo.color.color : _borderInfo.color));
|
|
|
|
}, me));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-12-09 08:50:32 +00:00
|
|
|
initTextFormat: function () {
|
|
|
|
var me = this,
|
|
|
|
$pageTextFormat = $('.page[data-page=edit-text-format]'),
|
2017-08-24 11:22:59 +00:00
|
|
|
hAlign = _cellInfo.asc_getHorAlign(),
|
|
|
|
vAlign = _cellInfo.asc_getVertAlign(),
|
|
|
|
hAlignStr = 'left',
|
|
|
|
vAlignStr = 'bottom',
|
2016-12-09 08:50:32 +00:00
|
|
|
isWrapText = _cellInfo.asc_getFlags().asc_getWrapText();
|
|
|
|
|
2017-08-24 11:22:59 +00:00
|
|
|
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));
|
2016-12-09 08:50:32 +00:00
|
|
|
|
|
|
|
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');
|
|
|
|
|
2017-08-24 11:22:59 +00:00
|
|
|
$radioHAlign.val([hAlignStr]);
|
|
|
|
$radioVAlign.val([vAlignStr]);
|
2016-12-09 08:50:32 +00:00
|
|
|
$switchWrapText.prop('checked', isWrapText);
|
|
|
|
|
|
|
|
$radioHAlign.single('change', _.bind(me.onHAlignChange, me));
|
|
|
|
$radioVAlign.single('change', _.bind(me.onVAlignChange, me));
|
|
|
|
$switchWrapText.single('change', _.bind(me.onWrapTextChange, me));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
initCellFormat: function () {
|
|
|
|
var me = this,
|
|
|
|
$pageCellFormat = $('.page[data-page=edit-cell-format]');
|
|
|
|
|
|
|
|
if ($pageCellFormat.length > 0) {
|
|
|
|
$pageCellFormat.find('.item-link.no-indicator[data-type]').single('click', _.bind(me.onCellFormat, me));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-12-09 12:44:26 +00:00
|
|
|
initBorderStyle: function () {
|
|
|
|
$('.page[data-page=edit-border-style] a[data-type]').single('click', _.bind(this.onBorderStyle, this));
|
|
|
|
|
2017-04-11 11:05:56 +00:00
|
|
|
$('#edit-border-color .color-preview').css('background-color', '#' + (_.isObject(_borderInfo.color) ? _borderInfo.color.color : _borderInfo.color));
|
2016-12-09 12:44:26 +00:00
|
|
|
$('#edit-border-size select').val(_borderInfo.width);
|
|
|
|
$('#edit-border-size .item-after').text($('#edit-border-size select option[value=' +_borderInfo.width + ']').text());
|
|
|
|
|
|
|
|
$('#edit-border-size select').single('change', function (e) {
|
|
|
|
_borderInfo.width = $(e.currentTarget).val();
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2016-12-09 08:50:32 +00:00
|
|
|
initFontSettings: function (fontObj) {
|
|
|
|
if (_.isUndefined(fontObj)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var me = this;
|
|
|
|
|
|
|
|
// Init font name
|
|
|
|
var fontName = fontObj.asc_getName() || this.textFonts;
|
|
|
|
_fontInfo.name = fontName;
|
|
|
|
|
|
|
|
$('#font-fonts .item-title').html(fontName);
|
|
|
|
|
|
|
|
|
|
|
|
// Init font style
|
|
|
|
$('#font-bold').toggleClass('active', fontObj.asc_getBold() === true);
|
|
|
|
$('#font-italic').toggleClass('active', fontObj.asc_getItalic() === true);
|
|
|
|
$('#font-underline').toggleClass('active', fontObj.asc_getUnderline() === true);
|
|
|
|
|
|
|
|
|
|
|
|
// Init font size
|
|
|
|
_fontInfo.size = fontObj.asc_getSize();
|
|
|
|
var displaySize = _fontInfo.size;
|
|
|
|
|
|
|
|
_.isUndefined(displaySize) ? displaySize = this.textAuto : displaySize = displaySize + ' ' + this.textPt;
|
|
|
|
|
|
|
|
$('#font-fonts .item-after span:first-child').html(displaySize);
|
|
|
|
$('#font-size .item-after label').html(displaySize);
|
|
|
|
|
|
|
|
|
|
|
|
// Init font color
|
|
|
|
_fontInfo.color = fontObj.asc_getColor();
|
|
|
|
|
|
|
|
var color = _fontInfo.color,
|
|
|
|
clr = me._sdkToThemeColor(color);
|
|
|
|
|
|
|
|
$('#text-color .color-preview').css('background-color', '#' + (_.isObject(clr) ? clr.color : clr));
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
initCellSettings: function (cellInfo) {
|
|
|
|
if (_.isUndefined(cellInfo)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var me = this,
|
|
|
|
selectionType = cellInfo.asc_getFlags().asc_getSelectionType(),
|
|
|
|
// coAuthDisable = (!this.toolbar.mode.isEditMailMerge && !this.toolbar.mode.isEditDiagram) ? (cellInfo.asc_getLocked()===true || cellInfo.asc_getLockedTable()===true) : false,
|
|
|
|
// editOptionsDisabled = this._disableEditOptions(selectionType, coAuthDisable),
|
|
|
|
_fontInfo = cellInfo.asc_getFont(),
|
|
|
|
val,
|
|
|
|
need_disable = false;
|
|
|
|
|
|
|
|
me.initFontSettings(_fontInfo);
|
|
|
|
|
|
|
|
// Init fill color
|
|
|
|
var color = cellInfo.asc_getFill().asc_getColor(),
|
|
|
|
clr = me._sdkToThemeColor(color);
|
|
|
|
|
|
|
|
$('#fill-color .color-preview').css('background-color', '#' + (_.isObject(clr) ? clr.color : clr));
|
|
|
|
|
2016-12-14 14:14:00 +00:00
|
|
|
var styleName = cellInfo.asc_getStyleName();
|
|
|
|
$('#edit-cell .cell-styles li[data-type="' + styleName + '"]').addClass('active');
|
2016-12-09 08:50:32 +00:00
|
|
|
|
|
|
|
if (selectionType == Asc.c_oAscSelectionType.RangeChart || selectionType == Asc.c_oAscSelectionType.RangeChartText) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
me.initTextFormat();
|
|
|
|
},
|
|
|
|
|
|
|
|
onApiInitEditorStyles: function(styles){
|
|
|
|
window.styles_loaded = false;
|
|
|
|
|
|
|
|
_cellStyles = styles.asc_getDefaultStyles().concat(styles.asc_getDocStyles());
|
|
|
|
|
|
|
|
this.getView('EditCell').renderStyles(_cellStyles);
|
|
|
|
|
|
|
|
window.styles_loaded = true;
|
2016-12-07 13:05:50 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Handlers
|
|
|
|
|
2016-12-09 08:50:32 +00:00
|
|
|
onFontSize: function (e) {
|
|
|
|
var me = this,
|
|
|
|
$button = $(e.currentTarget),
|
|
|
|
fontSize = _fontInfo.size;
|
|
|
|
|
|
|
|
if ($button.hasClass('decrement')) {
|
|
|
|
_.isUndefined(fontSize) ? me.api.asc_decreaseFontSize() : fontSize = Math.max(1, --fontSize);
|
|
|
|
} else {
|
|
|
|
_.isUndefined(fontSize) ? me.api.asc_increaseFontSize() : fontSize = Math.min(100, ++fontSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! _.isUndefined(fontSize)) {
|
|
|
|
me.api.asc_setCellFontSize(fontSize);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onFontClick: function (view, e) {
|
|
|
|
var $item = $(e.currentTarget).find('input');
|
|
|
|
|
|
|
|
if ($item) {
|
|
|
|
this.api.asc_setCellFontName($item.prop('value'));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-12-14 14:14:00 +00:00
|
|
|
onStyleClick: function (view, type) {
|
|
|
|
this.api.asc_setCellStyle(type);
|
|
|
|
},
|
|
|
|
|
2016-12-07 13:05:50 +00:00
|
|
|
onBold: function (e) {
|
|
|
|
var pressed = this._toggleButton(e);
|
|
|
|
|
|
|
|
if (this.api) {
|
2016-12-09 08:50:32 +00:00
|
|
|
this.api.asc_setCellBold(pressed);
|
2016-12-07 13:05:50 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onItalic: function (e) {
|
|
|
|
var pressed = this._toggleButton(e);
|
|
|
|
|
|
|
|
if (this.api) {
|
2016-12-09 08:50:32 +00:00
|
|
|
this.api.asc_setCellItalic(pressed);
|
2016-12-07 13:05:50 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onUnderline: function (e) {
|
|
|
|
var pressed = this._toggleButton(e);
|
|
|
|
|
|
|
|
if (this.api) {
|
2016-12-09 08:50:32 +00:00
|
|
|
this.api.asc_setCellUnderline(pressed);
|
2016-12-07 13:05:50 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-12-09 08:50:32 +00:00
|
|
|
onTextColor:function (palette, color) {
|
|
|
|
this.api.asc_setCellTextColor(Common.Utils.ThemeColor.getRgbColor(color));
|
|
|
|
},
|
|
|
|
|
|
|
|
onFillColor:function (palette, color) {
|
|
|
|
this.api.asc_setCellBackgroundColor(color == 'transparent' ? null : Common.Utils.ThemeColor.getRgbColor(color));
|
|
|
|
},
|
|
|
|
|
|
|
|
onHAlignChange: function (e) {
|
|
|
|
var $target = $(e.currentTarget),
|
2017-08-24 11:22:59 +00:00
|
|
|
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;
|
2016-12-09 08:50:32 +00:00
|
|
|
|
|
|
|
this.api.asc_setCellAlign(type);
|
|
|
|
},
|
|
|
|
|
|
|
|
onVAlignChange: function (e) {
|
|
|
|
var $target = $(e.currentTarget),
|
2017-08-24 11:22:59 +00:00
|
|
|
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;
|
|
|
|
}
|
2016-12-09 08:50:32 +00:00
|
|
|
|
|
|
|
this.api.asc_setCellVertAlign(type);
|
|
|
|
},
|
|
|
|
|
|
|
|
onWrapTextChange: function (e) {
|
|
|
|
var $target = $(e.currentTarget),
|
|
|
|
checked = $target.prop('checked');
|
|
|
|
|
|
|
|
this.api.asc_setCellTextWrap(checked);
|
|
|
|
},
|
|
|
|
|
|
|
|
onCellFormat: function (e) {
|
|
|
|
var $target = $(e.currentTarget),
|
|
|
|
type = decodeURIComponent(atob($target.data('type')));
|
|
|
|
|
|
|
|
this.api.asc_setCellFormat(type);
|
|
|
|
},
|
|
|
|
|
2016-12-09 12:44:26 +00:00
|
|
|
onBorderStyle: function (e) {
|
|
|
|
var me = this,
|
|
|
|
$target = $(e.currentTarget),
|
|
|
|
type = $target.data('type'),
|
|
|
|
newBorders = [],
|
|
|
|
bordersWidth = _borderInfo.width,
|
|
|
|
bordersColor = Common.Utils.ThemeColor.getRgbColor(_borderInfo.color);
|
|
|
|
|
|
|
|
if (type == 'inner') {
|
|
|
|
newBorders[Asc.c_oAscBorderOptions.InnerV] = new Asc.asc_CBorder(bordersWidth, bordersColor);
|
|
|
|
newBorders[Asc.c_oAscBorderOptions.InnerH] = new Asc.asc_CBorder(bordersWidth, bordersColor);
|
|
|
|
} else if (type == 'all') {
|
|
|
|
newBorders[Asc.c_oAscBorderOptions.InnerV] = new Asc.asc_CBorder(bordersWidth, bordersColor);
|
|
|
|
newBorders[Asc.c_oAscBorderOptions.InnerH] = new Asc.asc_CBorder(bordersWidth, bordersColor);
|
|
|
|
newBorders[Asc.c_oAscBorderOptions.Left] = new Asc.asc_CBorder(bordersWidth, bordersColor);
|
|
|
|
newBorders[Asc.c_oAscBorderOptions.Top] = new Asc.asc_CBorder(bordersWidth, bordersColor);
|
|
|
|
newBorders[Asc.c_oAscBorderOptions.Right] = new Asc.asc_CBorder(bordersWidth, bordersColor);
|
|
|
|
newBorders[Asc.c_oAscBorderOptions.Bottom] = new Asc.asc_CBorder(bordersWidth, bordersColor);
|
|
|
|
} else if (type == 'outer') {
|
|
|
|
newBorders[Asc.c_oAscBorderOptions.Left] = new Asc.asc_CBorder(bordersWidth, bordersColor);
|
|
|
|
newBorders[Asc.c_oAscBorderOptions.Top] = new Asc.asc_CBorder(bordersWidth, bordersColor);
|
|
|
|
newBorders[Asc.c_oAscBorderOptions.Right] = new Asc.asc_CBorder(bordersWidth, bordersColor);
|
|
|
|
newBorders[Asc.c_oAscBorderOptions.Bottom] = new Asc.asc_CBorder(bordersWidth, bordersColor);
|
|
|
|
} else if (type != 'none') {
|
|
|
|
var borderId = parseInt(type);
|
|
|
|
newBorders[borderId] = new Asc.asc_CBorder(bordersWidth, bordersColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
me.api.asc_setCellBorders(newBorders);
|
|
|
|
},
|
|
|
|
|
2016-12-07 13:05:50 +00:00
|
|
|
// API handlers
|
|
|
|
|
2016-12-09 08:50:32 +00:00
|
|
|
onApiEditorSelectionChanged: function(fontObj) {
|
|
|
|
if (!_isEdit) {
|
|
|
|
return;
|
|
|
|
}
|
2016-12-07 13:05:50 +00:00
|
|
|
|
2016-12-09 08:50:32 +00:00
|
|
|
_fontInfo = fontObj;
|
|
|
|
this.initFontSettings(fontObj);
|
|
|
|
},
|
|
|
|
|
|
|
|
onApiSelectionChanged: function(cellInfo) {
|
|
|
|
if (!_isEdit) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_cellInfo = cellInfo;
|
|
|
|
this.initCellSettings(cellInfo);
|
2016-12-07 13:05:50 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Helpers
|
|
|
|
_toggleButton: function (e) {
|
|
|
|
return $(e.currentTarget).toggleClass('active').hasClass('active');
|
|
|
|
},
|
|
|
|
|
2016-12-09 08:50:32 +00:00
|
|
|
_sdkToThemeColor: function (color) {
|
|
|
|
var clr = 'transparent';
|
|
|
|
|
|
|
|
if (color) {
|
|
|
|
if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) {
|
|
|
|
clr = {
|
|
|
|
color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()),
|
|
|
|
effectValue: color.get_value()
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
clr = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return clr;
|
|
|
|
},
|
|
|
|
|
2016-12-07 13:05:50 +00:00
|
|
|
textFonts: 'Fonts',
|
|
|
|
textAuto: 'Auto',
|
|
|
|
textPt: 'pt'
|
|
|
|
}
|
|
|
|
})(), SSE.Controllers.EditCell || {}))
|
|
|
|
});
|