From 744bef6f69f28d6796b5bed72b58759ab83670a6 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Tue, 11 Jun 2019 13:22:34 +0300 Subject: [PATCH] [SSE mobile] Add Formula Language --- .../mobile/app/controller/Settings.js | 39 +++++++- .../mobile/app/controller/add/AddFunction.js | 9 +- .../mobile/app/template/Settings.template | 37 +++++++- .../mobile/app/view/Settings.js | 41 ++++++++- .../mobile/app/view/add/AddFunction.js | 91 ++++++++++++++++--- 5 files changed, 199 insertions(+), 18 deletions(-) diff --git a/apps/spreadsheeteditor/mobile/app/controller/Settings.js b/apps/spreadsheeteditor/mobile/app/controller/Settings.js index c2985e259..3ef1c0f97 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Settings.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Settings.js @@ -76,7 +76,17 @@ define([ { caption: 'A2', subtitle: Common.Utils.String.format('42{0} x 59,4{0}', txtCm), value: [420, 594] }, { caption: 'A6', subtitle: Common.Utils.String.format('10,5{0} x 14,8{0}', txtCm), value: [105, 148] } ], - _metricText = Common.Utils.Metric.getMetricName(Common.Utils.Metric.getCurrentMetric()) + _metricText = Common.Utils.Metric.getMetricName(Common.Utils.Metric.getCurrentMetric()), + _dataLang = [ + { value: 'en', displayValue: 'English', exampleValue: ' SUM; MIN; MAX; COUNT' }, + { value: 'de', displayValue: 'Deutsch', exampleValue: ' SUMME; MIN; MAX; ANZAHL' }, + { value: 'es', displayValue: 'Spanish', exampleValue: ' SUMA; MIN; MAX; CALCULAR' }, + { value: 'fr', displayValue: 'French', exampleValue: ' SOMME; MIN; MAX; NB' }, + { value: 'it', displayValue: 'Italian', exampleValue: ' SOMMA; MIN; MAX; CONTA.NUMERI' }, + { value: 'ru', displayValue: 'Russian', exampleValue: ' СУММ; МИН; МАКС; СЧЁТ' }, + { value: 'pl', displayValue: 'Polish', exampleValue: ' SUMA; MIN; MAX; ILE.LICZB' } + ], + _indexLang = 0; var mm2Cm = function(mm) { return parseFloat((mm/10.).toFixed(2)); @@ -205,6 +215,8 @@ define([ me.initSpreadsheetPageSize(); } else if ('#margins-view' == pageId) { me.initSpreadsheetMargins(); + } else if ('#language-formula-view' == pageId) { + me.initFormulaLang(); } else { var _userCount = SSE.getController('Main').returnUserCount(); if (_userCount > 0) { @@ -213,6 +225,21 @@ define([ } }, + initFormulaLang: function() { + var value = Common.localStorage.getItem('sse-settings-func-lang'); + var item = _.findWhere(_dataLang, {value: value}); + this.getView('Settings').renderFormLang(item ? _dataLang.indexOf(item) : 0, _dataLang); + $('.page[data-page=language-formula-view] input:radio[name=language-formula]').single('change', _.bind(this.onFormulaLangChange, this)); + Common.Utils.addScrollIfNeed('.page[data-page=language-formula-view]', '.page[data-page=language-formula-view] .page-content'); + }, + + onFormulaLangChange: function(e) { + var langValue = $(e.currentTarget).val(); + Common.localStorage.setItem("sse-settings-func-lang", langValue); + this.initPageApplicationSettings(); + SSE.getController('AddFunction').onDocumentReady(); + }, + onCollaboration: function() { SSE.getController('Collaboration').showModal(); }, @@ -448,6 +475,16 @@ define([ var value = Common.localStorage.getItem('se-mobile-settings-unit'); value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); $unitMeasurement.val([value]); + + //init formula language + value = Common.localStorage.getItem('sse-settings-func-lang'); + var item = _.findWhere(_dataLang, {value: value}); + if(!item) { + item = _dataLang[0]; + } + var $pageLang = $('#language-formula'); + $pageLang.find('.item-title').text(item.displayValue); + $pageLang.find('.item-example').text(item.exampleValue); }, unitMeasurementChange: function (e) { diff --git a/apps/spreadsheeteditor/mobile/app/controller/add/AddFunction.js b/apps/spreadsheeteditor/mobile/app/controller/add/AddFunction.js index 4efe4024d..6dfa007d8 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/add/AddFunction.js +++ b/apps/spreadsheeteditor/mobile/app/controller/add/AddFunction.js @@ -86,7 +86,8 @@ define([ var me = this; _.defer(function () { - var editorLang = SSE.getController("Main").editorConfig.lang; + var editorLang = Common.localStorage.getItem('sse-settings-func-lang'); + editorLang = (editorLang ? editorLang : 'en').split(/[\-\_]/)[0].toLowerCase(); var localizationFunctions = function(data) { @@ -105,8 +106,8 @@ define([ fillFunctions: function() { var me = this, - functions = {}, - editorLang = SSE.getController("Main").editorConfig.lang; + functions = {}; + var editorLang = Common.localStorage.getItem('sse-settings-func-lang'); editorLang = (editorLang ? editorLang : 'en').split(/[\-\_]/)[0].toLowerCase(); @@ -141,7 +142,7 @@ define([ } } - view.setFunctions(functions); + view.setFunctions(functions, editorLang); view.render(); }; diff --git a/apps/spreadsheeteditor/mobile/app/template/Settings.template b/apps/spreadsheeteditor/mobile/app/template/Settings.template index 1faba16e0..476d744cd 100644 --- a/apps/spreadsheeteditor/mobile/app/template/Settings.template +++ b/apps/spreadsheeteditor/mobile/app/template/Settings.template @@ -414,7 +414,22 @@ - + +
<%= scope.textFormulaLanguage %>
+
+ +
@@ -641,4 +656,24 @@ + + + +
+ +
+
+
+
+
    +
+
+
+
+
\ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/app/view/Settings.js b/apps/spreadsheeteditor/mobile/app/view/Settings.js index ca0684bf9..21de71fb8 100644 --- a/apps/spreadsheeteditor/mobile/app/view/Settings.js +++ b/apps/spreadsheeteditor/mobile/app/view/Settings.js @@ -168,6 +168,11 @@ define([ showSetApp: function() { this.showPage('#settings-application-view'); + $('#language-formula').single('click', _.bind(this.showFormulaLanguage, this)); + }, + + showFormulaLanguage: function () { + this.showPage('#language-formula-view'); }, showColorSchemes: function () { @@ -261,6 +266,38 @@ define([ $list.html(items.join('')); }, + renderFormLang: function(indexLang, languages) { + var $pageLang = $('.page[data-page=language-formula-view]'), + $list = $pageLang.find('ul'), + items = [], + textEx = this.textExample; + + _.each(languages, function (lang, index) { + items.push(_.template([ + '
  • ', + '', + '
  • ' + ].join(''))({ + android: Framework7.prototype.device.android, + item: lang, + index: index, + selectIndex: indexLang, + textExamp: textEx + })); + }); + + $list.html(items.join('')); + }, + unknownText: 'Unknown', textFindAndReplace: 'Find and Replace', textSettings: 'Settings', @@ -304,7 +341,9 @@ define([ textLeft: 'Left', textBottom: 'Bottom', textRight: 'Right', - textCollaboration: 'Collaboration' + textCollaboration: 'Collaboration', + textFormulaLanguage: 'Formula Language', + textExample: 'Example' } })(), SSE.Views.Settings || {})) }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/app/view/add/AddFunction.js b/apps/spreadsheeteditor/mobile/app/view/add/AddFunction.js index d4777f34d..412b74035 100644 --- a/apps/spreadsheeteditor/mobile/app/view/add/AddFunction.js +++ b/apps/spreadsheeteditor/mobile/app/view/add/AddFunction.js @@ -109,17 +109,35 @@ define([ quickFunction.caption = me.functions[quickFunction.type].caption }); } + var lang = me.lang; + + this.translatTable = {}; + + var name = '', translate = '', + descriptions = ['DateAndTime', 'Engineering', 'Financial', 'Information', 'Logical', 'LookupAndReference', 'Mathematic', 'Statistical', 'TextAndData' ]; + for (var i=0; i').append(_.template(me.template)({ @@ -134,8 +152,9 @@ define([ return this; }, - setFunctions: function (arr) { + setFunctions: function (arr, lang) { this.functions = arr; + this.lang = lang; }, rootLayout: function () { @@ -202,7 +221,57 @@ define([ sCatLookupAndReference: 'Lookup and Reference', sCatMathematic: 'Math and trigonometry', sCatStatistical: 'Statistical', - sCatTextAndData: 'Text and data' + sCatTextAndData: 'Text and data', + + sCatDateAndTime_ru: 'Дата и время', + sCatEngineering_ru: 'Инженерные', + sCatFinancial_ru: 'Финансовые', + sCatInformation_ru: 'Информационные', + sCatLogical_ru: 'Логические', + sCatLookupAndReference_ru: 'Поиск и ссылки', + sCatMathematic_ru: 'Математические', + sCatStatistical_ru: 'Статистические', + sCatTextAndData_ru: 'Текст и данные', + + sCatLogical_es: 'Lógico', + sCatDateAndTime_es: 'Fecha y hora', + sCatEngineering_es: 'Ingenería', + sCatFinancial_es: 'Financial', + sCatInformation_es: 'Información', + sCatLookupAndReference_es: 'Búsqueda y referencia', + sCatMathematic_es: 'Matemáticas y trigonometría', + sCatStatistical_es: 'Estadístico', + sCatTextAndData_es: 'Texto y datos', + + sCatLogical_fr: 'Logique', + sCatDateAndTime_fr: 'Date et heure', + sCatEngineering_fr: 'Ingénierie', + sCatFinancial_fr: 'Financier', + sCatInformation_fr: 'Information', + sCatLookupAndReference_fr: 'Recherche et référence', + sCatMathematic_fr: 'Maths et trigonométrie', + sCatStatistical_fr: 'Statistiques', + sCatTextAndData_fr: 'Texte et données', + + sCatLogical_pl: 'Logiczny', + sCatDateAndTime_pl: 'Data i czas', + sCatEngineering_pl: 'Inżyniera', + sCatFinancial_pl: 'Finansowe', + sCatInformation_pl: 'Informacja', + sCatLookupAndReference_pl: 'Wyszukiwanie i odniesienie', + sCatMathematic_pl: 'Matematyczne i trygonometryczne', + sCatStatistical_pl: 'Statystyczny', + sCatTextAndData_pl: 'Tekst i data', + + sCatDateAndTime_de: 'Datum und Uhrzeit', + sCatEngineering_de: 'Konstruktion', + sCatFinancial_de: 'Finanzmathematik', + sCatInformation_de: 'Information', + sCatLogical_de: 'Logisch', + sCatLookupAndReference_de: 'Suchen und Bezüge', + sCatMathematic_de: 'Mathematik und Trigonometrie', + sCatStatistical_de: 'Statistik', + sCatTextAndData_de: 'Text und Daten' } })(), SSE.Views.AddFunction || {}));