From aea3758a4a032a9f0508323dd987e4fd8571f5d3 Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Thu, 18 Apr 2024 13:09:59 +0300 Subject: [PATCH] [DE mobile] refactoring --- apps/common/mobile/utils/htmlutils.js | 20 +++++++++++-------- apps/documenteditor/mobile/src/index_dev.html | 9 ++++----- .../src/view/settings/ApplicationSettings.jsx | 4 +--- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/apps/common/mobile/utils/htmlutils.js b/apps/common/mobile/utils/htmlutils.js index c82345f340..d9ec028990 100644 --- a/apps/common/mobile/utils/htmlutils.js +++ b/apps/common/mobile/utils/htmlutils.js @@ -24,18 +24,22 @@ function isLocalStorageAvailable() { } } -if(!window.lang) { - window.lang = (/(?:&|^)lang=([^&]+)&?/i).exec(window.location.search.substring(1)); - window.lang = window.lang ? window.lang[1] : ''; +{ + let lang = (/(?:&|^)lang=([^&]+)&?/i).exec(window.location.search.substring(1)); + lang = ((lang && lang[1]) || window.Common.Locale.defaultLang).split(/[\-\_]/)[0]; + Common.Locale.currentLang = lang; + Common.Locale.isCurrentLangRtl = lang.lastIndexOf('ar', 0) === 0; } -window.lang && (window.lang = window.lang.split(/[\-\_]/)[0].toLowerCase()); - if(isLocalStorageAvailable()) { - const modeDirection = localStorage.getItem('mobile-mode-direction'); + let modeDirection = localStorage.getItem('mobile-mode-direction'); - if(modeDirection === 'rtl' || (window.lang === 'ar' && !modeDirection)) { - !modeDirection && localStorage.setItem('mobile-mode-direction', 'rtl'); + if( !modeDirection && Common.Locale.isCurrentLangRtl ) { + localStorage.setItem('mobile-mode-direction', 'rtl'); + modeDirection = 'rtl'; + } + + if(modeDirection === 'rtl') { load_stylesheet('./css/framework7-rtl.css'); document.body.classList.add('rtl'); } else { diff --git a/apps/documenteditor/mobile/src/index_dev.html b/apps/documenteditor/mobile/src/index_dev.html index 83d28bd8ab..9fdd8137a0 100644 --- a/apps/documenteditor/mobile/src/index_dev.html +++ b/apps/documenteditor/mobile/src/index_dev.html @@ -23,6 +23,9 @@ + <% if ( htmlWebpackPlugin.options.skeleton.htmlscript ) { %> diff --git a/apps/documenteditor/mobile/src/view/settings/ApplicationSettings.jsx b/apps/documenteditor/mobile/src/view/settings/ApplicationSettings.jsx index c47af649e3..32175a75d8 100644 --- a/apps/documenteditor/mobile/src/view/settings/ApplicationSettings.jsx +++ b/apps/documenteditor/mobile/src/view/settings/ApplicationSettings.jsx @@ -25,8 +25,6 @@ const PageApplicationSettings = props => { // set mode const appOptions = props.storeAppOptions; - const currentLang = appOptions.lang; - const isRtlLang = currentLang && /^(ar)$/i.test(currentLang); const colorTheme = storeThemes.colorTheme; const themes = storeThemes.themes; const typeTheme = colorTheme.type; @@ -114,7 +112,7 @@ const PageApplicationSettings = props => { }}> } - {isRtlLang && + {Common.Locale.isCurrentLangRtl && <>