From 652fafcbedcbca67dc08aa0f9cd3258a83516f89 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Fri, 12 Apr 2019 14:32:19 +0300 Subject: [PATCH] [pe mobile] added application settings (units) --- .../mobile/app/controller/Settings.js | 19 ++++++ .../mobile/app/controller/edit/EditChart.js | 4 +- .../mobile/app/controller/edit/EditShape.js | 4 +- .../mobile/app/controller/edit/EditTable.js | 5 +- .../mobile/app/controller/edit/EditText.js | 2 + .../mobile/app/template/Settings.template | 65 +++++++++++++++++++ .../mobile/app/view/Settings.js | 12 +++- apps/presentationeditor/mobile/locale/en.json | 5 ++ 8 files changed, 109 insertions(+), 7 deletions(-) diff --git a/apps/presentationeditor/mobile/app/controller/Settings.js b/apps/presentationeditor/mobile/app/controller/Settings.js index 222c16a6d..59c3e019c 100644 --- a/apps/presentationeditor/mobile/app/controller/Settings.js +++ b/apps/presentationeditor/mobile/app/controller/Settings.js @@ -175,9 +175,28 @@ define([ } else if (pageId == '#settings-about-view') { // About me.setLicInfo(_licInfo); + } else if ('#settings-application-view' == pageId) { + me.initPageApplicationSettings(); } }, + initPageApplicationSettings: function () { + var me = this, + $unitMeasurement = $('.page[data-page=settings-application-view] input:radio[name=unit-of-measurement]'); + $unitMeasurement.single('change', _.bind(me.unitMeasurementChange, me)); + var value = Common.localStorage.getItem('pe-mobile-settings-unit'); + value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); + $unitMeasurement.val([value]); + }, + + unitMeasurementChange: function (e) { + var value = $(e.currentTarget).val(); + value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); + Common.Utils.Metric.setCurrentMetric(value); + Common.localStorage.setItem("pe-mobile-settings-unit", value); + this.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); + }, + setLicInfo: function(data){ if (data && typeof data == 'object' && typeof(data.customer)=='object') { $('.page[data-page=settings-about-view] .logo').hide(); diff --git a/apps/presentationeditor/mobile/app/controller/edit/EditChart.js b/apps/presentationeditor/mobile/app/controller/edit/EditChart.js index e03437470..1372edec8 100644 --- a/apps/presentationeditor/mobile/app/controller/edit/EditChart.js +++ b/apps/presentationeditor/mobile/app/controller/edit/EditChart.js @@ -166,7 +166,7 @@ define([ var borderSize = shapeProperties.get_stroke().get_width() * 72.0 / 25.4, borderType = _shapeObject.get_stroke().get_type(); $('#edit-chart-bordersize input').val([(borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.indexSizeByValue(borderSize)]); - $('#edit-chart-bordersize .item-after').text(((borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.sizeByValue(borderSize)) + ' ' + _metricText); + $('#edit-chart-bordersize .item-after').text(((borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.sizeByValue(borderSize)) + ' ' + Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt)); paletteFillColor && paletteFillColor.on('select', _.bind(me.onFillColor, me)); paletteBorderColor && paletteBorderColor.on('select', _.bind(me.onBorderColor, me)); @@ -330,7 +330,7 @@ define([ onBorderSizeChanging: function (e) { var $target = $(e.currentTarget); - $('#edit-chart-bordersize .item-after').text(borderSizeTransform.sizeByIndex($target.val()) + ' ' + _metricText); + $('#edit-chart-bordersize .item-after').text(borderSizeTransform.sizeByIndex($target.val()) + ' ' + Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt)); }, onFillColor: function(palette, color) { diff --git a/apps/presentationeditor/mobile/app/controller/edit/EditShape.js b/apps/presentationeditor/mobile/app/controller/edit/EditShape.js index 8ca49d3d0..3f264a65b 100644 --- a/apps/presentationeditor/mobile/app/controller/edit/EditShape.js +++ b/apps/presentationeditor/mobile/app/controller/edit/EditShape.js @@ -157,7 +157,7 @@ define([ var borderSize = _shapeObject.get_stroke().get_width() * 72.0 / 25.4, borderType = _shapeObject.get_stroke().get_type(); $('#edit-shape-bordersize input').val([(borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.indexSizeByValue(borderSize)]); - $('#edit-shape-bordersize .item-after').text(((borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.sizeByValue(borderSize)) + ' ' + _metricText); + $('#edit-shape-bordersize .item-after').text(((borderType == Asc.c_oAscStrokeType.STROKE_NONE) ? 0 : borderSizeTransform.sizeByValue(borderSize)) + ' ' + Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt)); // Init style opacity $('#edit-shape-effect input').val([_shapeObject.get_fill().asc_getTransparent() ? _shapeObject.get_fill().asc_getTransparent() / 2.55 : 100]); @@ -306,7 +306,7 @@ define([ onBorderSizeChanging: function (e) { var $target = $(e.currentTarget); - $('#edit-shape-bordersize .item-after').text(borderSizeTransform.sizeByIndex($target.val()) + ' ' + _metricText); + $('#edit-shape-bordersize .item-after').text(borderSizeTransform.sizeByIndex($target.val()) + ' ' + Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt)); }, onOpacity: function (e) { diff --git a/apps/presentationeditor/mobile/app/controller/edit/EditTable.js b/apps/presentationeditor/mobile/app/controller/edit/EditTable.js index 4837138b7..ee7bce32a 100644 --- a/apps/presentationeditor/mobile/app/controller/edit/EditTable.js +++ b/apps/presentationeditor/mobile/app/controller/edit/EditTable.js @@ -167,6 +167,7 @@ define([ initSettings: function (pageId) { var me = this; + _metricText = Common.Utils.Metric.getMetricName(Common.Utils.Metric.getCurrentMetric()); if (_tableObject) { if (pageId == "#edit-table-style" || pageId == '#edit-table-border-color-view') { me._initStyleView(); @@ -268,7 +269,7 @@ define([ // } $('#edit-table-bordersize input').val([borderSizeTransform.indexSizeByValue(_cellBorderWidth)]); - $('#edit-table-bordersize .item-after').text(borderSizeTransform.sizeByValue(_cellBorderWidth) + ' ' + _metricText); + $('#edit-table-bordersize .item-after').text(borderSizeTransform.sizeByValue(_cellBorderWidth) + ' ' + Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt)); var borderPalette = me.getView('EditTable').paletteBorderColor; @@ -464,7 +465,7 @@ define([ onBorderSizeChanging: function (e) { var $target = $(e.currentTarget); - $('#edit-table-bordersize .item-after').text(borderSizeTransform.sizeByIndex($target.val()) + ' ' + _metricText); + $('#edit-table-bordersize .item-after').text(borderSizeTransform.sizeByIndex($target.val()) + ' ' + Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt)); }, onReorder: function (e) { diff --git a/apps/presentationeditor/mobile/app/controller/edit/EditText.js b/apps/presentationeditor/mobile/app/controller/edit/EditText.js index b89a43cfd..546cea397 100644 --- a/apps/presentationeditor/mobile/app/controller/edit/EditText.js +++ b/apps/presentationeditor/mobile/app/controller/edit/EditText.js @@ -170,6 +170,8 @@ define([ initSettings: function (pageId) { var me = this; + metricText = Common.Utils.Metric.getMetricName(Common.Utils.Metric.getCurrentMetric()); + me.api && me.api.UpdateInterfaceState(); // TODO: refactor me if (_paragraphObject) { diff --git a/apps/presentationeditor/mobile/app/template/Settings.template b/apps/presentationeditor/mobile/app/template/Settings.template index 52494bc42..6fd7a4afb 100644 --- a/apps/presentationeditor/mobile/app/template/Settings.template +++ b/apps/presentationeditor/mobile/app/template/Settings.template @@ -77,6 +77,18 @@ +
  • + +
    +
    + +
    +
    +
    <%= scope.textApplicationSettings %>
    +
    +
    +
    +
  • @@ -342,4 +354,57 @@
    + + + +
    + +
    +
    +
    +
    <%= scope.textUnitOfMeasurement %>
    +
    + +
      +
    • + +
    • +
    • + +
    • +
    • + +
    • +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/apps/presentationeditor/mobile/app/view/Settings.js b/apps/presentationeditor/mobile/app/view/Settings.js index e31e4d909..a5510db8a 100644 --- a/apps/presentationeditor/mobile/app/view/Settings.js +++ b/apps/presentationeditor/mobile/app/view/Settings.js @@ -80,6 +80,7 @@ define([ $('#settings-help').single('click', _.bind(me.showHelp, me)); $('#settings-about').single('click', _.bind(me.showAbout, me)); $('#settings-presentation-setup').single('click', _.bind(me.showSetup, me)); + $('#settings-application').single('click', _.bind(me.showSetApp, me)); Common.Utils.addScrollIfNeed('.view[data-page=settings-root-view] .pages', '.view[data-page=settings-root-view] .page'); me.initControls(); @@ -192,6 +193,10 @@ define([ this.showPage('#settings-setup-view'); }, + showSetApp: function () { + this.showPage('#settings-application-view'); + }, + loadDocument: function (data) { var permissions = {}; @@ -229,7 +234,12 @@ define([ textPoweredBy: 'Powered by', textFindAndReplace: 'Find and Replace', textSpellcheck: 'Spell Checking', - textPrint: 'Print' + textPrint: 'Print', + textApplicationSettings: 'Application Settings', + textUnitOfMeasurement: 'Unit of Measurement', + textCentimeter: 'Centimeter', + textPoint: 'Point', + textInch: 'Inch' } })(), PE.Views.Settings || {})) }); \ No newline at end of file diff --git a/apps/presentationeditor/mobile/locale/en.json b/apps/presentationeditor/mobile/locale/en.json index 3cf5ab52e..95a83c7dc 100644 --- a/apps/presentationeditor/mobile/locale/en.json +++ b/apps/presentationeditor/mobile/locale/en.json @@ -465,6 +465,11 @@ "PE.Views.Settings.textSpellcheck": "Spell Checking", "PE.Views.Settings.textTel": "tel", "PE.Views.Settings.textVersion": "Version", + "DE.Views.Settings.textApplicationSettings": "Application Settings", + "DE.Views.Settings.textUnitOfMeasurement": "Unit of Measurement", + "DE.Views.Settings.textCentimeter": "Centimeter", + "DE.Views.Settings.textPoint": "Point", + "DE.Views.Settings.textInch": "Inch", "PE.Views.Settings.unknownText": "Unknown", "PE.Views.Toolbar.textBack": "Back" } \ No newline at end of file