/* * * (c) Copyright Ascensio System SIA 2010-2019 * * 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 20A-12 Ernesta Birznieka-Upisha * street, Riga, Latvia, EU, LV-1050. * * 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 4/15/14 * Copyright (c) 2018 Ascensio System SIA. All rights reserved. * */ define([ 'text!presentationeditor/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/ListView' ], function (contentTemplate) { 'use strict'; PE.Views.ParagraphSettingsAdvanced = Common.Views.AdvancedSettingsWindow.extend(_.extend({ options: { contentWidth: 370, height: 394, toggleGroup: 'paragraph-adv-settings-group', storageName: 'pe-para-settings-adv-category' }, initialize : function(options) { var me = this; _.extend(this.options, { title: this.textTitle, items: [ {panelId: 'id-adv-paragraph-indents', panelCaption: this.strParagraphIndents}, {panelId: 'id-adv-paragraph-font', panelCaption: this.strParagraphFont}, {panelId: 'id-adv-paragraph-tabs', panelCaption: this.strTabs} ], contentTemplate: _.template(contentTemplate)({ scope: this }) }, options); Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); this._changedProps = null; this.checkGroup = 0; // 1-strike, 2-sub/super-script, 3-caps this._noApply = true; this._tabListChanged = false; this.spinners = []; this.FirstLine = undefined; this.Spacing = null; this.api = this.options.api; this._originalProps = new Asc.asc_CParagraphProperty(this.options.paragraphProps); this._arrLineRule = [ {displayValue: this.textAuto, defaultValue: 1, value: c_paragraphLinerule.LINERULE_AUTO, minValue: 0.5, step: 0.01, defaultUnit: ''}, {displayValue: this.textExact, defaultValue: 5, value: c_paragraphLinerule.LINERULE_EXACT, minValue: 0.03, step: 0.01, defaultUnit: 'cm'} ]; var curLineRule = this._originalProps.get_Spacing().get_LineRule(), curItem = _.findWhere(this._arrLineRule, {value: curLineRule}); this.CurLineRuleIdx = this._arrLineRule.indexOf(curItem); this._arrTextAlignment = [ {displayValue: this.textTabLeft, value: c_paragraphTextAlignment.LEFT}, {displayValue: this.textTabCenter, value: c_paragraphTextAlignment.CENTERED}, {displayValue: this.textTabRight, value: c_paragraphTextAlignment.RIGHT}, {displayValue: this.textJustified, value: c_paragraphTextAlignment.JUSTIFIED} ]; this._arrSpecial = [ {displayValue: this.textNoneSpecial, value: c_paragraphSpecial.NONE_SPECIAL, defaultValue: 0}, {displayValue: this.textFirstLine, value: c_paragraphSpecial.FIRST_LINE, defaultValue: 12.7}, {displayValue: this.textHanging, value: c_paragraphSpecial.HANGING, defaultValue: 12.7} ]; this._arrTabAlign = [ { value: Asc.c_oAscTabType.Left, displayValue: this.textTabLeft }, { value: Asc.c_oAscTabType.Center, displayValue: this.textTabCenter }, { value: Asc.c_oAscTabType.Right, displayValue: this.textTabRight } ]; this._arrKeyTabAlign = []; this._arrTabAlign.forEach(function(item) { me._arrKeyTabAlign[item.value] = item.displayValue; }); }, render: function() { Common.Views.AdvancedSettingsWindow.prototype.render.call(this); var me = this; // Indents & Placement this.cmbTextAlignment = new Common.UI.ComboBox({ el: $('#paragraphadv-spin-text-alignment'), cls: 'input-group-nr', editable: false, data: this._arrTextAlignment, style: 'width: 173px;', menuStyle : 'min-width: 173px;' }); this.cmbTextAlignment.setValue(''); 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: 0 }); this.numIndentsLeft.on('change', _.bind(function(field, newValue, oldValue, eOpts){ var numval = field.getNumberValue(); 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(numval)); } }, 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: 0 }); 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.cmbSpecial = new Common.UI.ComboBox({ el: $('#paragraphadv-spin-special'), cls: 'input-group-nr', editable: false, data: this._arrSpecial, style: 'width: 85px;', menuStyle : 'min-width: 85px;' }); this.cmbSpecial.setValue(''); this.cmbSpecial.on('selected', _.bind(this.onSpecialSelect, this)); this.numSpecialBy = new Common.UI.MetricSpinner({ el: $('#paragraphadv-spin-special-by'), step: .1, width: 85, defaultUnit : "cm", defaultValue : 0, value: '0 cm', maxValue: 55.87, minValue: 0 }); this.spinners.push(this.numSpecialBy); this.numSpecialBy.on('change', _.bind(this.onFirstLineChange, this)); this.numSpacingBefore = new Common.UI.MetricSpinner({ el: $('#paragraphadv-spin-spacing-before'), step: .1, width: 85, value: '', defaultUnit : "cm", maxValue: 55.88, minValue: 0, allowAuto : true, autoText : this.txtAutoText }); this.numSpacingBefore.on('change', _.bind(function (field, newValue, oldValue, eOpts) { if (this.Spacing === null) { var properties = (this._originalProps) ? this._originalProps : new Asc.asc_CParagraphProperty(); this.Spacing = properties.get_Spacing(); } this.Spacing.put_Before(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); }, this)); this.spinners.push(this.numSpacingBefore); this.numSpacingAfter = new Common.UI.MetricSpinner({ el: $('#paragraphadv-spin-spacing-after'), step: .1, width: 85, value: '', defaultUnit : "cm", maxValue: 55.88, minValue: 0, allowAuto : true, autoText : this.txtAutoText }); this.numSpacingAfter.on('change', _.bind(function (field, newValue, oldValue, eOpts) { if (this.Spacing === null) { var properties = (this._originalProps) ? this._originalProps : new Asc.asc_CParagraphProperty(); this.Spacing = properties.get_Spacing(); } this.Spacing.put_After(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue())); }, this)); this.spinners.push(this.numSpacingAfter); this.cmbLineRule = new Common.UI.ComboBox({ el: $('#paragraphadv-spin-line-rule'), cls: 'input-group-nr', editable: false, data: this._arrLineRule, style: 'width: 85px;', menuStyle : 'min-width: 85px;' }); this.cmbLineRule.setValue(this.CurLineRuleIdx); this.cmbLineRule.on('selected', _.bind(this.onLineRuleSelect, this)); this.numLineHeight = new Common.UI.MetricSpinner({ el: $('#paragraphadv-spin-line-height'), step: .01, width: 85, value: '', defaultUnit : "", maxValue: 132, minValue: 0.5 }); this.spinners.push(this.numLineHeight); this.numLineHeight.on('change', _.bind(this.onNumLineHeightChange, this)); // 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); // Tabs this.numTab = new Common.UI.MetricSpinner({ el: $('#paraadv-spin-tab'), step: .1, width: 108, 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: 108, 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(), template: _.template(['
'].join('')), itemTemplate: _.template([ '