/* * * (c) Copyright Ascensio System Limited 2010-2016 * * 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 * * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, * EU, LV-1021. * * 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 * */ /** * ParagraphSettingsAdvanced.js * * Created by Julia Radzhabova on 2/21/14 * Copyright (c) 2014 Ascensio System SIA. All rights reserved. * */ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.template', 'common/main/lib/view/AdvancedSettingsWindow', 'common/main/lib/component/MetricSpinner', 'common/main/lib/component/CheckBox', 'common/main/lib/component/RadioBox', 'common/main/lib/component/ThemeColorPalette', 'common/main/lib/component/ColorButton', 'common/main/lib/component/ListView', 'common/main/lib/component/TableStyler' ], function (contentTemplate) { 'use strict'; DE.Views.ParagraphSettingsAdvanced = Common.Views.AdvancedSettingsWindow.extend(_.extend({ options: { contentWidth: 325, height: 394, toggleGroup: 'paragraph-adv-settings-group', storageName: 'de-para-settings-adv-category' }, initialize : function(options) { _.extend(this.options, { title: this.textTitle, items: [ {panelId: 'id-adv-paragraph-indents', panelCaption: this.strParagraphIndents}, {panelId: 'id-adv-paragraph-borders', panelCaption: this.strBorders}, {panelId: 'id-adv-paragraph-font', panelCaption: this.strParagraphFont}, {panelId: 'id-adv-paragraph-tabs', panelCaption: this.strTabs}, {panelId: 'id-adv-paragraph-margins', panelCaption: this.strMargins} ], contentTemplate: _.template(contentTemplate)({ scope: this }) }, options); Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); this.Borders = {}; this.BorderSize = {ptValue: 0, pxValue: 0}; this.paragraphShade = 'transparent'; this._changedProps = null; this.ChangedBorders = undefined; // undefined - не менялись, null - применялись пресеты, отправлять Borders, object - менялись отдельные границы, отправлять ChangedBorders this.checkGroup = 0; // 1-strike, 2-sub/super-script, 3-caps this._noApply = true; this._tabListChanged = false; this.Margins = undefined; this.spinners = []; this.tableStylerRows = this.options.tableStylerRows; this.tableStylerColumns = this.options.tableStylerColumns; this.borderProps = this.options.borderProps; this.api = this.options.api; this._originalProps = new Asc.asc_CParagraphProperty(this.options.paragraphProps); this.isChart = this.options.isChart; }, render: function() { Common.Views.AdvancedSettingsWindow.prototype.render.call(this); var me = this; // Indents & Placement this.numFirstLine = new Common.UI.MetricSpinner({ el: $('#paragraphadv-spin-first-line'), step: .1, width: 85, defaultUnit : "cm", defaultValue : 0, value: '0 cm', maxValue: 55.87, minValue: -55.87 }); this.numFirstLine.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) { if (this._changedProps.get_Ind()===null || this._changedProps.get_Ind()===undefined) this._changedProps.put_Ind(new Asc.asc_CParagraphInd()); this._changedProps.get_Ind().put_FirstLine(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); } }, this)); this.spinners.push(this.numFirstLine); this.numIndentsLeft = new Common.UI.MetricSpinner({ el: $('#paragraphadv-spin-indent-left'), step: .1, width: 85, defaultUnit : "cm", defaultValue : 0, value: '0 cm', maxValue: 55.87, minValue: -55.87 }); this.numIndentsLeft.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) { if (this._changedProps.get_Ind()===null || this._changedProps.get_Ind()===undefined) this._changedProps.put_Ind(new Asc.asc_CParagraphInd()); this._changedProps.get_Ind().put_Left(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); } }, this)); this.spinners.push(this.numIndentsLeft); this.numIndentsRight = new Common.UI.MetricSpinner({ el: $('#paragraphadv-spin-indent-right'), step: .1, width: 85, defaultUnit : "cm", defaultValue : 0, value: '0 cm', maxValue: 55.87, minValue: -55.87 }); this.numIndentsRight.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) { if (this._changedProps.get_Ind()===null || this._changedProps.get_Ind()===undefined) this._changedProps.put_Ind(new Asc.asc_CParagraphInd()); this._changedProps.get_Ind().put_Right(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); } }, this)); this.spinners.push(this.numIndentsRight); this.chBreakBefore = new Common.UI.CheckBox({ el: $('#paragraphadv-checkbox-break-before'), labelText: this.strBreakBefore }); this.chBreakBefore.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) { this._changedProps.put_PageBreakBefore(field.getValue()=='checked'); } }, this)); this.chKeepLines = new Common.UI.CheckBox({ el: $('#paragraphadv-checkbox-keep-lines'), labelText: this.strKeepLines }); this.chKeepLines.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) { this._changedProps.put_KeepLines(field.getValue()=='checked'); } }, this)); this.chOrphan = new Common.UI.CheckBox({ el: $('#paragraphadv-checkbox-orphan'), labelText: this.strOrphan }); this.chOrphan.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) { this._changedProps.put_WidowControl(field.getValue()=='checked'); } }, this)); this.chKeepNext = new Common.UI.CheckBox({ el: $('#paragraphadv-checkbox-keep-next'), labelText: this.strKeepNext }); this.chKeepNext.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) { this._changedProps.put_KeepNext(field.getValue()=='checked'); } }, this)); // Borders this.cmbBorderSize = new Common.UI.ComboBorderSize({ el: $('#paragraphadv-combo-border-size'), style: "width: 93px;" }); var rec = this.cmbBorderSize.store.at(2); this.BorderSize = {ptValue: rec.get('value'), pxValue: rec.get('pxValue')}; this.cmbBorderSize.setValue(this.BorderSize.ptValue); this.cmbBorderSize.on('selected', _.bind(this.onBorderSizeSelect, this)); this.btnBorderColor = new Common.UI.ColorButton({ style: "width:45px;", menu : new Common.UI.Menu({ items: [ { template: _.template('
') }, { template: _.template('' + me.textNewColor + '') } ] }) }); this.btnBorderColor.on('render:after', function(btn) { me.colorsBorder = new Common.UI.ThemeColorPalette({ el: $('#paragraphadv-border-color-menu'), dynamiccolors: 10, colors: [ me.textThemeColors, '-', {color: '3366FF', effectId: 1}, {color: '0000FF', effectId: 2}, {color: '000090', effectId: 3}, {color: '660066', effectId: 4}, {color: '800000', effectId: 5}, {color: 'FF0000', effectId: 1}, {color: 'FF6600', effectId: 1}, {color: 'FFFF00', effectId: 2}, {color: 'CCFFCC', effectId: 3}, {color: '008000', effectId: 4}, '-', {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2}, {color: '000000', effectId: 3}, {color: 'FFFFFF', effectId: 4}, {color: '000000', effectId: 5}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, '-', '--', '-', me.textStandartColors, '-', '3D55FE', '5301B3', '980ABD', 'B2275F', 'F83D26', 'F86A1D', 'F7AC16', 'F7CA12', 'FAFF44', 'D6EF39', '-', '--' ] }); me.colorsBorder.on('select', _.bind(me.onColorsBorderSelect, me)); }); this.btnBorderColor.render( $('#paragraphadv-border-color-btn')); this.btnBorderColor.setColor('000000'); $('#paragraphadv-border-color-new').on('click', _.bind(this.addNewColor, this, this.colorsBorder, this.btnBorderColor)); this.BordersImage = new Common.UI.TableStyler({ el: $('#id-deparagraphstyler'), width: 200, height: 170, rows: this.tableStylerRows, columns: this.tableStylerColumns, spacingMode: false }); var _arrBorderPresets = [ ['lrtb', 'btn-borders-large btn-adv-paragraph-outer', 'paragraphadv-button-border-outer', this.tipOuter], ['lrtbm', 'btn-borders-large btn-adv-paragraph-all', 'paragraphadv-button-border-all', this.tipAll], ['', 'btn-borders-large btn-adv-paragraph-none', 'paragraphadv-button-border-none', this.tipNone], ['l', 'btn-borders-large btn-adv-paragraph-left', 'paragraphadv-button-border-left', this.tipLeft], ['r', 'btn-borders-large btn-adv-paragraph-right', 'paragraphadv-button-border-right', this.tipRight], ['t', 'btn-borders-large btn-adv-paragraph-top', 'paragraphadv-button-border-top', this.tipTop], ['m', 'btn-borders-large btn-adv-paragraph-inner-hor', 'paragraphadv-button-border-inner-hor', this.tipInner], ['b', 'btn-borders-large btn-adv-paragraph-bottom', 'paragraphadv-button-border-bottom', this.tipBottom] ]; this._btnsBorderPosition = []; _.each(_arrBorderPresets, function(item, index, list){ var _btn = new Common.UI.Button({ style: 'margin-left: 5px; margin-bottom: 4px;', cls: 'btn-options large', iconCls: item[1], strId :item[0], hint: item[3] }); _btn.render( $('#'+item[2])) ; _btn.on('click', _.bind(this._ApplyBorderPreset, this)); this._btnsBorderPosition.push( _btn ); }, this); this.btnBackColor = new Common.UI.ColorButton({ style: "width:45px;", menu : new Common.UI.Menu({ items: [ { template: _.template('') }, { template: _.template('' + me.textNewColor + '') } ] }) }); this.btnBackColor.on('render:after', function(btn) { me.colorsBack = new Common.UI.ThemeColorPalette({ el: $('#paragraphadv-back-color-menu'), dynamiccolors: 10, colors: [ me.textThemeColors, '-', {color: '3366FF', effectId: 1}, {color: '0000FF', effectId: 2}, {color: '000090', effectId: 3}, {color: '660066', effectId: 4}, {color: '800000', effectId: 5}, {color: 'FF0000', effectId: 1}, {color: 'FF6600', effectId: 1}, {color: 'FFFF00', effectId: 2}, {color: 'CCFFCC', effectId: 3}, {color: '008000', effectId: 4}, '-', {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2}, {color: '000000', effectId: 3}, {color: 'FFFFFF', effectId: 4}, {color: '000000', effectId: 5}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, {color: 'FFFFFF', effectId: 2},{color: '000000', effectId: 1}, '-', '--', '-', me.textStandartColors, '-', 'transparent', '5301B3', '980ABD', 'B2275F', 'F83D26', 'F86A1D', 'F7AC16', 'F7CA12', 'FAFF44', 'D6EF39', '-', '--' ] }); me.colorsBack.on('select', _.bind(me.onColorsBackSelect, me)); }); this.btnBackColor.render( $('#paragraphadv-back-color-btn')); $('#paragraphadv-back-color-new').on('click', _.bind(this.addNewColor, this, this.colorsBack, this.btnBackColor)); // Font this.chStrike = new Common.UI.CheckBox({ el: $('#paragraphadv-checkbox-strike'), labelText: this.strStrike }); this.chStrike.on('change', _.bind(this.onStrikeChange, this)); this.chDoubleStrike = new Common.UI.CheckBox({ el: $('#paragraphadv-checkbox-double-strike'), labelText: this.strDoubleStrike }); this.chDoubleStrike.on('change', _.bind(this.onDoubleStrikeChange, this)); this.chSuperscript = new Common.UI.CheckBox({ el: $('#paragraphadv-checkbox-superscript'), labelText: this.strSuperscript }); this.chSuperscript.on('change', _.bind(this.onSuperscriptChange, this)); this.chSubscript = new Common.UI.CheckBox({ el: $('#paragraphadv-checkbox-subscript'), labelText: this.strSubscript }); this.chSubscript.on('change', _.bind(this.onSubscriptChange, this)); this.chSmallCaps = new Common.UI.CheckBox({ el: $('#paragraphadv-checkbox-small-caps'), labelText: this.strSmallCaps }); this.chSmallCaps.on('change', _.bind(this.onSmallCapsChange, this)); this.chAllCaps = new Common.UI.CheckBox({ el: $('#paragraphadv-checkbox-all-caps'), labelText: this.strAllCaps }); this.chAllCaps.on('change', _.bind(this.onAllCapsChange, this)); this.numSpacing = new Common.UI.MetricSpinner({ el: $('#paragraphadv-spin-spacing'), step: .01, width: 100, defaultUnit : "cm", defaultValue : 0, value: '0 cm', maxValue: 55.87, minValue: -55.87 }); this.numSpacing.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) { this._changedProps.put_TextSpacing(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); } if (this.api && !this._noApply) { var properties = (this._originalProps) ? this._originalProps : new Asc.asc_CParagraphProperty(); properties.put_TextSpacing(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); this.api.SetDrawImagePlaceParagraph('paragraphadv-font-img', properties); } }, this)); this.spinners.push(this.numSpacing); this.numPosition = new Common.UI.MetricSpinner({ el: $('#paragraphadv-spin-position'), step: .01, width: 100, defaultUnit : "cm", defaultValue : 0, value: '0 cm', maxValue: 55.87, minValue: -55.87 }); this.numPosition.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) { this._changedProps.put_Position(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); } if (this.api && !this._noApply) { var properties = (this._originalProps) ? this._originalProps : new Asc.asc_CParagraphProperty(); properties.put_Position(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); this.api.SetDrawImagePlaceParagraph('paragraphadv-font-img', properties); } }, this)); this.spinners.push(this.numPosition); // Tabs this.numTab = new Common.UI.MetricSpinner({ el: $('#paraadv-spin-tab'), step: .1, width: 180, defaultUnit : "cm", value: '1.25 cm', maxValue: 55.87, minValue: 0 }); this.spinners.push(this.numTab); this.numDefaultTab = new Common.UI.MetricSpinner({ el: $('#paraadv-spin-default-tab'), step: .1, width: 107, defaultUnit : "cm", value: '1.25 cm', maxValue: 55.87, minValue: 0 }); this.numDefaultTab.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (this._changedProps) { this._changedProps.put_DefaultTab(parseFloat(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue()).toFixed(1))); } }, this)); this.spinners.push(this.numDefaultTab); this.tabList = new Common.UI.ListView({ el: $('#paraadv-list-tabs'), emptyText: this.noTabs, store: new Common.UI.DataViewStore() }); this.tabList.store.comparator = function(rec) { return rec.get("tabPos"); }; this.tabList.on('item:select', _.bind(this.onSelectTab, this)); var storechanged = function() { if (!me._noApply) me._tabListChanged = true; }; this.listenTo(this.tabList.store, 'add', storechanged); this.listenTo(this.tabList.store, 'remove', storechanged); this.listenTo(this.tabList.store, 'reset', storechanged); this.radioLeft = new Common.UI.RadioBox({ el: $('#paragraphadv-radio-left'), labelText: this.textTabLeft, name: 'asc-radio-tab', checked: true }); this.radioCenter = new Common.UI.RadioBox({ el: $('#paragraphadv-radio-center'), labelText: this.textTabCenter, name: 'asc-radio-tab' }); this.radioRight = new Common.UI.RadioBox({ el: $('#paragraphadv-radio-right'), labelText: this.textTabRight, name: 'asc-radio-tab' }); this.btnAddTab = new Common.UI.Button({ el: $('#paraadv-button-add-tab') }); this.btnAddTab.on('click', _.bind(this.addTab, this)); this.btnRemoveTab = new Common.UI.Button({ el: $('#paraadv-button-remove-tab') }); this.btnRemoveTab.on('click', _.bind(this.removeTab, this)); this.btnRemoveAll = new Common.UI.Button({ el: $('#paraadv-button-remove-all') }); this.btnRemoveAll.on('click', _.bind(this.removeAllTabs, this)); // Margins this.spnMarginTop = new Common.UI.MetricSpinner({ el: $('#paraadv-number-margin-top'), step: .1, width: 100, defaultUnit : "cm", value: '0 cm', maxValue: 55.87, minValue: 0 }); this.spnMarginTop.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (!this._noApply) { if (this.Margins===undefined) this.Margins = {}; this.Margins.Top = Common.Utils.Metric.fnRecalcToMM(field.getNumberValue()); } }, this)); this.spinners.push(this.spnMarginTop); this.spnMarginBottom = new Common.UI.MetricSpinner({ el: $('#paraadv-number-margin-bottom'), step: .1, width: 100, defaultUnit : "cm", value: '0 cm', maxValue: 55.87, minValue: 0 }); this.spnMarginBottom.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (!this._noApply) { if (this.Margins===undefined) this.Margins = {}; this.Margins.Bottom = Common.Utils.Metric.fnRecalcToMM(field.getNumberValue()); } }, this)); this.spinners.push(this.spnMarginBottom); this.spnMarginLeft = new Common.UI.MetricSpinner({ el: $('#paraadv-number-margin-left'), step: .1, width: 100, defaultUnit : "cm", value: '0.19 cm', maxValue: 9.34, minValue: 0 }); this.spnMarginLeft.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (!this._noApply) { if (this.Margins===undefined) this.Margins = {}; this.Margins.Left = Common.Utils.Metric.fnRecalcToMM(field.getNumberValue()); } }, this)); this.spinners.push(this.spnMarginLeft); this.spnMarginRight = new Common.UI.MetricSpinner({ el: $('#paraadv-number-margin-right'), step: .1, width: 100, defaultUnit : "cm", value: '0.19 cm', maxValue: 9.34, minValue: 0 }); this.spnMarginRight.on('change', _.bind(function(field, newValue, oldValue, eOpts){ if (!this._noApply) { if (this.Margins===undefined) this.Margins = {}; this.Margins.Right = Common.Utils.Metric.fnRecalcToMM(field.getNumberValue()); } }, this)); this.spinners.push(this.spnMarginRight); this.TextOnlySettings = $('.text-only'); this.afterRender(); }, getSettings: function() { if ( this.ChangedBorders === null ) { this._changedProps.put_Borders(this.Borders); } else if (this.ChangedBorders !== undefined) { this._changedProps.put_Borders(this.ChangedBorders); } if (this.Margins) { var borders = this._changedProps.get_Borders(); if (borders===undefined || borders===null) { this._changedProps.put_Borders(new Asc.asc_CParagraphBorders()); borders = this._changedProps.get_Borders(); } if (this.Margins.Left!==undefined) { if (borders.get_Left()===undefined || borders.get_Left()===null) borders.put_Left(new Asc.asc_CTextBorder(this.Borders.get_Left())); borders.get_Left().put_Space(this.Margins.Left); } if (this.Margins.Top!==undefined) { if (borders.get_Top()===undefined || borders.get_Top()===null) borders.put_Top(new Asc.asc_CTextBorder(this.Borders.get_Top())); borders.get_Top().put_Space(this.Margins.Top); } if (this.Margins.Right!==undefined) { if (borders.get_Right()===undefined || borders.get_Right()===null) borders.put_Right(new Asc.asc_CTextBorder(this.Borders.get_Right())); borders.get_Right().put_Space(this.Margins.Right); } if (this.Margins.Bottom!==undefined) { if (borders.get_Bottom()===undefined || borders.get_Bottom()===null) borders.put_Bottom(new Asc.asc_CTextBorder(this.Borders.get_Bottom())); borders.get_Bottom().put_Space(this.Margins.Bottom); if (borders.get_Between()===undefined || borders.get_Between()===null) borders.put_Between(new Asc.asc_CTextBorder(this.Borders.get_Between())); borders.get_Between().put_Space(this.Margins.Bottom); } } if ( this._tabListChanged ) { if (this._changedProps.get_Tabs()===null || this._changedProps.get_Tabs()===undefined) this._changedProps.put_Tabs(new Asc.asc_CParagraphTabs()); this.tabList.store.each(function (item, index) { var tab = new Asc.asc_CParagraphTab(Common.Utils.Metric.fnRecalcToMM(item.get('tabPos')), item.get('tabAlign')); this._changedProps.get_Tabs().add_Tab(tab); }, this); } return { paragraphProps: this._changedProps, borderProps: {borderSize: this.BorderSize, borderColor: this.btnBorderColor.color} }; }, _setDefaults: function(props) { if (props ){ this._originalProps = new Asc.asc_CParagraphProperty(props); this.hideTextOnlySettings(this.isChart); this.numFirstLine.setValue((props.get_Ind() !== null && props.get_Ind().get_FirstLine() !== null ) ? Common.Utils.Metric.fnRecalcFromMM(props.get_Ind().get_FirstLine()) : '', true); this.numIndentsLeft.setValue((props.get_Ind() !== null && props.get_Ind().get_Left() !== null) ? Common.Utils.Metric.fnRecalcFromMM(props.get_Ind().get_Left()) : '', true); this.numIndentsRight.setValue((props.get_Ind() !== null && props.get_Ind().get_Right() !== null) ? Common.Utils.Metric.fnRecalcFromMM(props.get_Ind().get_Right()) : '', true); this.chKeepLines.setValue((props.get_KeepLines() !== null && props.get_KeepLines() !== undefined) ? props.get_KeepLines() : 'indeterminate', true); this.chBreakBefore.setValue((props.get_PageBreakBefore() !== null && props.get_PageBreakBefore() !== undefined) ? props.get_PageBreakBefore() : 'indeterminate', true); this.chKeepNext.setValue((props.get_KeepNext() !== null && props.get_KeepNext() !== undefined) ? props.get_KeepNext() : 'indeterminate', true); this.chOrphan.setValue((props.get_WidowControl() !== null && props.get_WidowControl() !== undefined) ? props.get_WidowControl() : 'indeterminate', true); this.Borders = new Asc.asc_CParagraphBorders(props.get_Borders()); // Margins if (this.Borders) { var brd = this.Borders.get_Left(); var val = (null !== brd && undefined !== brd && null !== brd.get_Space() && undefined !== brd.get_Space()) ? Common.Utils.Metric.fnRecalcFromMM(brd.get_Space()) : ''; this.spnMarginLeft.setValue(val, true); brd = this.Borders.get_Top(); val = (null !== brd && undefined !== brd && null !== brd.get_Space() && undefined !== brd.get_Space()) ? Common.Utils.Metric.fnRecalcFromMM(brd.get_Space()) : ''; this.spnMarginTop.setValue(val, true); brd = this.Borders.get_Right(); val = (null !== brd && undefined !== brd && null !== brd.get_Space() && undefined !== brd.get_Space()) ? Common.Utils.Metric.fnRecalcFromMM(brd.get_Space()) : ''; this.spnMarginRight.setValue(val, true); brd = this.Borders.get_Bottom(); val = (null !== brd && undefined !== brd && null !== brd.get_Space() && undefined !== brd.get_Space()) ? Common.Utils.Metric.fnRecalcFromMM(brd.get_Space()) : ''; this.spnMarginBottom.setValue(val, true); } // Borders var shd = props.get_Shade(); if (shd!==null && shd!==undefined && shd.get_Value()===Asc.c_oAscShdClear) { var color = shd.get_Color(); if (color) { if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { this.paragraphShade = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value()}; } else { this.paragraphShade = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); } } else this.paragraphShade = 'transparent'; } else { this.paragraphShade = 'transparent'; } this.btnBackColor.setColor(this.paragraphShade); if ( typeof(this.paragraphShade) == 'object' ) { var isselected = false; for (var i=0; i<10; i++) { if ( Common.Utils.ThemeColor.ThemeValues[i] == this.paragraphShade.effectValue ) { this.colorsBack.select(this.paragraphShade,true); isselected = true; break; } } if (!isselected) this.colorsBack.clearSelection(); } else this.colorsBack.select(this.paragraphShade,true); this._UpdateBorders(); // Font this._noApply = true; this.chStrike.setValue((props.get_Strikeout() !== null && props.get_Strikeout() !== undefined) ? props.get_Strikeout() : 'indeterminate', true); this.chDoubleStrike.setValue((props.get_DStrikeout() !== null && props.get_DStrikeout() !== undefined) ? props.get_DStrikeout() : 'indeterminate', true); this.chSubscript.setValue((props.get_Subscript() !== null && props.get_Subscript() !== undefined) ? props.get_Subscript() : 'indeterminate', true); this.chSuperscript.setValue((props.get_Superscript() !== null && props.get_Superscript() !== undefined) ? props.get_Superscript() : 'indeterminate', true); this.chSmallCaps.setValue((props.get_SmallCaps() !== null && props.get_SmallCaps() !== undefined) ? props.get_SmallCaps() : 'indeterminate', true); this.chAllCaps.setValue((props.get_AllCaps() !== null && props.get_AllCaps() !== undefined) ? props.get_AllCaps() : 'indeterminate', true); this.numSpacing.setValue((props.get_TextSpacing() !== null && props.get_TextSpacing() !== undefined) ? Common.Utils.Metric.fnRecalcFromMM(props.get_TextSpacing()) : '', true); this.numPosition.setValue((props.get_Position() !== null && props.get_Position() !== undefined) ? Common.Utils.Metric.fnRecalcFromMM(props.get_Position()) : '', true); this.api.SetDrawImagePlaceParagraph('paragraphadv-font-img', this._originalProps); // Tabs this.numDefaultTab.setValue((props.get_DefaultTab() !== null && props.get_DefaultTab() !== undefined) ? Common.Utils.Metric.fnRecalcFromMM(parseFloat(props.get_DefaultTab().toFixed(1))) : '', true); var store = this.tabList.store; var tabs = props.get_Tabs(); if (tabs) { var arr = []; var count = tabs.get_Count(); for (var i=0; i