[SSE mobile] Add Formula Language

This commit is contained in:
Julia Svinareva 2019-06-11 13:22:34 +03:00
parent 304baedd80
commit 744bef6f69
5 changed files with 199 additions and 18 deletions

View file

@ -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) {

View file

@ -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();
};

View file

@ -414,7 +414,22 @@
</label>
</li>
</ul>
</div>
</div>
<div class="content-block-title"><%= scope.textFormulaLanguage %></div>
<div class="list-block">
<ul>
<li class="media-item">
<a id="language-formula" class="item-link item-content" data-page="#language-formula-view">
<div class="item-inner">
<div class="item-title-row">
<div class="item-title"><%= scope.textCustom %></div>
</div>
<div class="item-subtitle"><%= scope.textExample + ": "%><span class="item-example"><%= scope.textCustomSize %></span></div>
</div>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
@ -641,4 +656,24 @@
</div>
</div>
</div>
</div>
<!-- Language Formula View --->
<div id="language-formula-view">
<div class="navbar">
<div class="navbar-inner">
<div class="left sliding"><a href="#" class="back link"> <i class="icon icon-back"></i><% if (!android) { %><span><%= scope.textBack %></span><% } %></a></div>
<div class="center sliding"><%= scope.textFormulaLanguage %></div>
</div>
</div>
<div class="pages">
<div class="page" data-page="language-formula-view">
<div class="page-content">
<div class="list-block media-list">
<ul>
</ul>
</div>
</div>
</div>
</div>
</div>

View file

@ -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([
'<li>',
'<label class="label-radio item-content">',
'<input type="radio" name="language-formula" value="<%= item.value %>" <% if (index == selectIndex) { %>checked="checked"<% } %> >',
'<% if (android) { %><div class="item-media"><i class="icon icon-form-radio"></i></div><% } %>',
'<div class="item-inner">',
'<div class="item-title-row">',
'<div class="item-title"><%= item.displayValue %></div>',
'</div>',
'<div class="item-subtitle"><%= textExamp + ": "%> <%= item.exampleValue %></div>',
'</div>',
'</label>',
'</li>'
].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 || {}))
});

View file

@ -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<descriptions.length; i++) {
name = descriptions[i];
translate = 'sCat' + name;
this.translatTable[name] = {
en: this[translate],
de: this[translate+'_de'],
ru: this[translate+'_ru'],
pl: this[translate+'_pl'],
es: this[translate+'_es'],
fr: this[translate+'_fr']
};
}
me.groups = {
'DateAndTime': me.sCatDateAndTime,
'Engineering': me.sCatEngineering,
'TextAndData': me.sCatTextAndData,
'Statistical': me.sCatStatistical,
'Financial': me.sCatFinancial,
'Mathematic': me.sCatMathematic,
'LookupAndReference': me.sCatLookupAndReference,
'Information': me.sCatInformation,
'Logical': me.sCatLogical
'DateAndTime': me.translatTable['DateAndTime'][lang] || me.translatTable['DateAndTime']['en'],
'Engineering': me.translatTable['Engineering'][lang] || me.translatTable['Engineering']['en'],
'TextAndData': me.translatTable['TextAndData'][lang] || me.translatTable['TextAndData']['en'],
'Statistical': me.translatTable['Statistical'][lang] || me.translatTable['Statistical']['en'],
'Financial': me.translatTable['Financial'][lang] || me.translatTable['Financial']['en'],
'Mathematic': me.translatTable['Mathematic'][lang] || me.translatTable['Mathematic']['en'],
'LookupAndReference': me.translatTable['LookupAndReference'][lang] || me.translatTable['LookupAndReference']['en'],
'Information': me.translatTable['Information'][lang] || me.translatTable['Information']['en'],
'Logical': me.translatTable['Logical'][lang] || me.translatTable['Logical']['en']
};
me.layout = $('<div/>').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 || {}));