From 2592bffef1df37996f8d521ba247d2fa277b2a62 Mon Sep 17 00:00:00 2001 From: Alexander Yuzhin Date: Wed, 13 Mar 2019 13:59:41 +0300 Subject: [PATCH] [de] Add edit of first line of the paragraph --- .../app/controller/edit/EditParagraph.js | 35 +++++++++++++++++-- .../app/template/EditParagraph.template | 15 ++++++++ .../mobile/app/view/edit/EditParagraph.js | 1 + apps/documenteditor/mobile/locale/ru.json | 1 + 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js b/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js index 105d1e5c7..efd160e66 100644 --- a/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js +++ b/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js @@ -54,6 +54,7 @@ define([ var _stack = [], _paragraphInfo = {}, _paragraphObject = undefined, + _paragraphProperty = undefined, _styles = [], _styleThumbSize, _styleName, @@ -113,6 +114,7 @@ define([ $('#paragraph-distance-before .button').single('click', _.bind(me.onDistanceBefore, me)); $('#paragraph-distance-after .button').single('click', _.bind(me.onDistanceAfter, me)); + $('#paragraph-spin-first-line .button').single('click', _.bind(me.onSpinFirstLine, me)); $('#paragraph-space input:checkbox').single('change', _.bind(me.onSpaceBetween, me)); $('#paragraph-page-break input:checkbox').single('change', _.bind(me.onBreakBefore, me)); $('#paragraph-page-orphan input:checkbox').single('change', _.bind(me.onOrphan, me)); @@ -127,6 +129,23 @@ define([ initSettings: function () { var me = this; + var selectedElements = me.api.getSelectedElements(); + if (selectedElements && _.isArray(selectedElements)) { + for (var i = selectedElements.length - 1; i >= 0; i--) { + if (Asc.c_oAscTypeSelectElement.Paragraph == selectedElements[i].get_ObjectType()) { + _paragraphProperty = selectedElements[i].get_ObjectValue(); + break; + } + } + } + + if (_paragraphProperty) { + if (_paragraphProperty.get_Ind()===null || _paragraphProperty.get_Ind()===undefined) { + _paragraphProperty.get_Ind().put_FirstLine(0); + } + $('#paragraph-spin-first-line .item-after label').text(_paragraphProperty.get_Ind().get_FirstLine() + ' ' + metricText); + } + if (_paragraphObject) { _paragraphInfo.spaceBefore = _paragraphObject.get_Spacing().get_Before() < 0 ? _paragraphObject.get_Spacing().get_Before() : Common.Utils.Metric.fnRecalcFromMM(_paragraphObject.get_Spacing().get_Before()); _paragraphInfo.spaceAfter = _paragraphObject.get_Spacing().get_After() < 0 ? _paragraphObject.get_Spacing().get_After() : Common.Utils.Metric.fnRecalcFromMM(_paragraphObject.get_Spacing().get_After()); @@ -236,12 +255,22 @@ define([ } else { distance = Math.min(100, ++distance); } + }, - _paragraphInfo.spaceAfter = distance; + onSpinFirstLine: function(e) { + var $button = $(e.currentTarget), + distance = _paragraphProperty.get_Ind().get_FirstLine(); - $('#paragraph-distance-after .item-after label').text(_paragraphInfo.spaceAfter < 0 ? 'Auto' : (_paragraphInfo.spaceAfter) + ' ' + metricText); + if ($button.hasClass('decrement')) { + distance = Math.max(-999, --distance); + } else { + distance = Math.min(999, ++distance); + } - this.api.put_LineSpacingBeforeAfter(1, (_paragraphInfo.spaceAfter < 0) ? -1 : Common.Utils.Metric.fnRecalcToMM(_paragraphInfo.spaceAfter)); + _paragraphProperty.get_Ind().put_FirstLine(distance) + + $('#paragraph-spin-first-line .item-after label').text(distance + ' ' + metricText); + this.api.paraApply(_paragraphProperty); }, onSpaceBetween: function (e) { diff --git a/apps/documenteditor/mobile/app/template/EditParagraph.template b/apps/documenteditor/mobile/app/template/EditParagraph.template index 8ffe07692..5abd3fcf1 100644 --- a/apps/documenteditor/mobile/app/template/EditParagraph.template +++ b/apps/documenteditor/mobile/app/template/EditParagraph.template @@ -92,6 +92,21 @@ +
  • +
    +
    +
    <%= scope.textFirstLine %>
    +
    + <% if (!android) { %><% } %> +

    + <% if (android) { %><% } else { %>-<% } %> + <% if (android) { %><% } %> + <% if (android) { %><% } else { %>+<% } %> +

    +
    +
    +
    +
  • diff --git a/apps/documenteditor/mobile/app/view/edit/EditParagraph.js b/apps/documenteditor/mobile/app/view/edit/EditParagraph.js index 7d16001f9..af5665588 100644 --- a/apps/documenteditor/mobile/app/view/edit/EditParagraph.js +++ b/apps/documenteditor/mobile/app/view/edit/EditParagraph.js @@ -165,6 +165,7 @@ define([ textFromText: 'Distance from Text', textBefore: 'Before', textAuto: 'Auto', + textFirstLine: 'First Line', textAfter: 'After', textSpaceBetween: 'Space Between Paragraphs', textPageBreak: 'Page Break Before', diff --git a/apps/documenteditor/mobile/locale/ru.json b/apps/documenteditor/mobile/locale/ru.json index 37bf15d21..8c274c8f2 100644 --- a/apps/documenteditor/mobile/locale/ru.json +++ b/apps/documenteditor/mobile/locale/ru.json @@ -273,6 +273,7 @@ "DE.Views.EditParagraph.textAdvSettings": "Дополнительно", "DE.Views.EditParagraph.textAfter": "После", "DE.Views.EditParagraph.textAuto": "Авто", + "DE.Views.EditParagraph.textFirstLine": "Первоя строка", "DE.Views.EditParagraph.textBack": "Назад", "DE.Views.EditParagraph.textBackground": "Фон", "DE.Views.EditParagraph.textBefore": "Перед",