From c2013f48afab1a2978940c2e79d9121decd3a383 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Thu, 25 Apr 2019 13:55:59 +0300 Subject: [PATCH] [DE mobile] Fix units in paragraph --- .../app/controller/edit/EditParagraph.js | 74 +++++++++++++++---- 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js b/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js index 25f694e77..a6fba2535 100644 --- a/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js +++ b/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js @@ -144,7 +144,8 @@ define([ 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); + + $('#paragraph-spin-first-line .item-after label').text(Common.Utils.Metric.fnRecalcFromMM(_paragraphProperty.get_Ind().get_FirstLine()) + ' ' + metricText); } if (_paragraphObject) { @@ -232,50 +233,93 @@ define([ onDistanceBefore: function (e) { var $button = $(e.currentTarget), - distance = _paragraphInfo.spaceBefore; + distance = _paragraphInfo.spaceBefore, + step, + maxValue; + + if (Common.Utils.Metric.getCurrentMetric() == Common.Utils.Metric.c_MetricUnits.pt) { + step = 1; + } else { + step = 0.01; + } + + maxValue = Common.Utils.Metric.fnRecalcFromMM(558.8); if ($button.hasClass('decrement')) { - distance = Math.max(-1, --distance); + distance = Math.max(-1, distance - step); } else { - distance = Math.min(100, ++distance); + distance = Math.min(maxValue, distance + step); } + var distanceFix = distance.toFixed(2); + _paragraphInfo.spaceBefore = distance; - $('#paragraph-distance-before .item-after label').text(_paragraphInfo.spaceBefore < 0 ? 'Auto' : (_paragraphInfo.spaceBefore) + ' ' + metricText); + $('#paragraph-distance-before .item-after label').text(_paragraphInfo.spaceBefore < 0 ? 'Auto' : distanceFix + ' ' + metricText); this.api.put_LineSpacingBeforeAfter(0, (_paragraphInfo.spaceBefore < 0) ? -1 : Common.Utils.Metric.fnRecalcToMM(_paragraphInfo.spaceBefore)); }, onDistanceAfter: function (e) { var $button = $(e.currentTarget), - distance = _paragraphInfo.spaceAfter; + distance = _paragraphInfo.spaceAfter, + step, + maxValue; + + if (Common.Utils.Metric.getCurrentMetric() == Common.Utils.Metric.c_MetricUnits.pt) { + step = 1; + } else { + step = 0.01; + } + + maxValue = Common.Utils.Metric.fnRecalcFromMM(558.8); if ($button.hasClass('decrement')) { - distance = Math.max(-1, --distance); + distance = Math.max(-1, distance - step); } else { - distance = Math.min(100, ++distance); + distance = Math.min(maxValue, distance + step); } + var distanceFix = distance.toFixed(2); + _paragraphInfo.spaceAfter = distance; - $('#paragraph-distance-after .item-after label').text(_paragraphInfo.spaceAfter < 0 ? 'Auto' : (_paragraphInfo.spaceAfter) + ' ' + metricText); + $('#paragraph-distance-after .item-after label').text(_paragraphInfo.spaceAfter < 0 ? 'Auto' : distanceFix + ' ' + metricText); this.api.put_LineSpacingBeforeAfter(1, (_paragraphInfo.spaceAfter < 0) ? -1 : Common.Utils.Metric.fnRecalcToMM(_paragraphInfo.spaceAfter)); }, onSpinFirstLine: function(e) { var $button = $(e.currentTarget), - distance = _paragraphProperty.get_Ind().get_FirstLine(); + distance = _paragraphProperty.get_Ind().get_FirstLine(), + step, + minValue, + maxValue; - if ($button.hasClass('decrement')) { - distance = Math.max(-999, --distance); + distance = Common.Utils.Metric.fnRecalcFromMM(distance); + + if (Common.Utils.Metric.getCurrentMetric() == Common.Utils.Metric.c_MetricUnits.pt) { + step = 1; } else { - distance = Math.min(999, ++distance); + step = 0.1; } - _paragraphProperty.get_Ind().put_FirstLine(distance) + minValue = Common.Utils.Metric.fnRecalcFromMM(-558.7); + maxValue = Common.Utils.Metric.fnRecalcFromMM(558.7); + + if ($button.hasClass('decrement')) { + distance = Math.max(minValue, distance - step); + } else { + distance = Math.min(maxValue, distance + step); + } + + var distanceFix = distance.toFixed(2); + + $('#paragraph-spin-first-line .item-after label').text(distanceFix + ' ' + metricText); + + distance = Common.Utils.Metric.fnRecalcToMM(distance); + + _paragraphProperty.get_Ind().put_FirstLine(distance); - $('#paragraph-spin-first-line .item-after label').text(distance + ' ' + metricText); this.api.paraApply(_paragraphProperty); },