From 2ecc9404538121c20322d4766f428232020ba634 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Tue, 16 Apr 2024 14:25:11 +0300 Subject: [PATCH 1/3] [common] Add rtl option blocking for non-rtl languages --- apps/common/mobile/utils/htmlutils.js | 12 +++++- .../src/view/settings/ApplicationSettings.jsx | 40 +++++++++++-------- .../src/view/settings/ApplicationSettings.jsx | 40 +++++++++++-------- .../src/view/settings/ApplicationSettings.jsx | 40 +++++++++++-------- 4 files changed, 80 insertions(+), 52 deletions(-) diff --git a/apps/common/mobile/utils/htmlutils.js b/apps/common/mobile/utils/htmlutils.js index d7b448e1d6..c82345f340 100644 --- a/apps/common/mobile/utils/htmlutils.js +++ b/apps/common/mobile/utils/htmlutils.js @@ -24,8 +24,18 @@ function isLocalStorageAvailable() { } } +if(!window.lang) { + window.lang = (/(?:&|^)lang=([^&]+)&?/i).exec(window.location.search.substring(1)); + window.lang = window.lang ? window.lang[1] : ''; +} + +window.lang && (window.lang = window.lang.split(/[\-\_]/)[0].toLowerCase()); + if(isLocalStorageAvailable()) { - if(localStorage.getItem('mobile-mode-direction') === 'rtl') { + const modeDirection = localStorage.getItem('mobile-mode-direction'); + + if(modeDirection === 'rtl' || (window.lang === 'ar' && !modeDirection)) { + !modeDirection && localStorage.setItem('mobile-mode-direction', 'rtl'); load_stylesheet('./css/framework7-rtl.css'); document.body.classList.add('rtl'); } else { diff --git a/apps/documenteditor/mobile/src/view/settings/ApplicationSettings.jsx b/apps/documenteditor/mobile/src/view/settings/ApplicationSettings.jsx index 80ed1e26a5..c47af649e3 100644 --- a/apps/documenteditor/mobile/src/view/settings/ApplicationSettings.jsx +++ b/apps/documenteditor/mobile/src/view/settings/ApplicationSettings.jsx @@ -25,6 +25,8 @@ 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; @@ -112,23 +114,27 @@ const PageApplicationSettings = props => { }}> } - - -
- {t("Settings.textRtlInterface")} - Beta -
- { - storeApplicationSettings.changeDirectionMode(newDirectionMode); - props.changeDirectionMode(newDirectionMode); - }} - /> -
-
- -

{t('Settings.textExplanationChangeDirection')}

-
+ {isRtlLang && + <> + + +
+ {t("Settings.textRtlInterface")} + Beta +
+ { + storeApplicationSettings.changeDirectionMode(newDirectionMode); + props.changeDirectionMode(newDirectionMode); + }} + /> +
+
+ +

{t('Settings.textExplanationChangeDirection')}

+
+ + } ); }; diff --git a/apps/presentationeditor/mobile/src/view/settings/ApplicationSettings.jsx b/apps/presentationeditor/mobile/src/view/settings/ApplicationSettings.jsx index 23012d14a5..cc6a2fb22d 100644 --- a/apps/presentationeditor/mobile/src/view/settings/ApplicationSettings.jsx +++ b/apps/presentationeditor/mobile/src/view/settings/ApplicationSettings.jsx @@ -19,6 +19,8 @@ const PageApplicationSettings = props => { // set mode const appOptions = props.storeAppOptions; + const currentLang = appOptions.lang; + const isRtlLang = currentLang && /^(ar)$/i.test(currentLang); const storeThemes = props.storeThemes; const colorTheme = storeThemes.colorTheme; const themes = storeThemes.themes; @@ -66,23 +68,27 @@ const PageApplicationSettings = props => { setMacrosSettings: props.setMacrosSettings }}> - - -
- {t("View.Settings.textRtlInterface")} - Beta -
- { - storeApplicationSettings.changeDirectionMode(newDirectionMode); - props.changeDirectionMode(newDirectionMode); - }} - /> -
-
- -

{t('View.Settings.textExplanationChangeDirection')}

-
+ {isRtlLang && + <> + + +
+ {t("View.Settings.textRtlInterface")} + Beta +
+ { + storeApplicationSettings.changeDirectionMode(newDirectionMode); + props.changeDirectionMode(newDirectionMode); + }} + /> +
+
+ +

{t('View.Settings.textExplanationChangeDirection')}

+
+ + } ); }; diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/ApplicationSettings.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/ApplicationSettings.jsx index cccb47d17f..dc13c3be71 100644 --- a/apps/spreadsheeteditor/mobile/src/view/settings/ApplicationSettings.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/settings/ApplicationSettings.jsx @@ -31,6 +31,8 @@ const PageApplicationSettings = props => { // set mode const appOptions = props.storeAppOptions; const storeThemes = props.storeThemes; + const currentLang = appOptions.lang; + const isRtlLang = currentLang && /^(ar)$/i.test(currentLang); const colorTheme = storeThemes.colorTheme; const themes = storeThemes.themes; const isConfigSelectTheme = storeThemes.isConfigSelectTheme; @@ -109,23 +111,27 @@ const PageApplicationSettings = props => { onChangeMacrosSettings: props.onChangeMacrosSettings }}> - - -
- {t("View.Settings.textRtlInterface")} - Beta -
- { - storeApplicationSettings.changeDirectionMode(newDirectionMode); - props.changeDirectionMode(newDirectionMode); - }} - /> -
-
- -

{t('View.Settings.textExplanationChangeDirection')}

-
+ {isRtlLang && + <> + + +
+ {t("View.Settings.textRtlInterface")} + Beta +
+ { + storeApplicationSettings.changeDirectionMode(newDirectionMode); + props.changeDirectionMode(newDirectionMode); + }} + /> +
+
+ +

{t('View.Settings.textExplanationChangeDirection')}

+
+ + } ); }; From aea3758a4a032a9f0508323dd987e4fd8571f5d3 Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Thu, 18 Apr 2024 13:09:59 +0300 Subject: [PATCH 2/3] [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 && Common.Locale.isCurrentLangRtl ) { + localStorage.setItem('mobile-mode-direction', 'rtl'); + modeDirection = 'rtl'; + } - if(modeDirection === 'rtl' || (window.lang === 'ar' && !modeDirection)) { - !modeDirection && localStorage.setItem('mobile-mode-direction', '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 && <> From 980f950961ecb1f6d5c2823673c1ffd2854e365c Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Thu, 25 Apr 2024 11:18:54 +0300 Subject: [PATCH 3/3] [PE SSE mobile] Refactoring lock rtl options --- apps/common/mobile/utils/htmlutils.js | 2 +- apps/presentationeditor/mobile/src/index_dev.html | 9 ++++----- .../mobile/src/view/settings/ApplicationSettings.jsx | 5 +---- apps/spreadsheeteditor/mobile/src/index_dev.html | 9 ++++----- .../mobile/src/view/settings/ApplicationSettings.jsx | 4 +--- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/apps/common/mobile/utils/htmlutils.js b/apps/common/mobile/utils/htmlutils.js index d9ec028990..3fb8f384b5 100644 --- a/apps/common/mobile/utils/htmlutils.js +++ b/apps/common/mobile/utils/htmlutils.js @@ -34,7 +34,7 @@ function isLocalStorageAvailable() { if(isLocalStorageAvailable()) { let modeDirection = localStorage.getItem('mobile-mode-direction'); - if( !modeDirection && Common.Locale.isCurrentLangRtl ) { + if(!modeDirection && Common.Locale.isCurrentLangRtl) { localStorage.setItem('mobile-mode-direction', 'rtl'); modeDirection = 'rtl'; } diff --git a/apps/presentationeditor/mobile/src/index_dev.html b/apps/presentationeditor/mobile/src/index_dev.html index d5996c2973..9dc9765a05 100644 --- a/apps/presentationeditor/mobile/src/index_dev.html +++ b/apps/presentationeditor/mobile/src/index_dev.html @@ -24,6 +24,9 @@ + <% if ( htmlWebpackPlugin.options.skeleton.htmlscript ) { %> diff --git a/apps/presentationeditor/mobile/src/view/settings/ApplicationSettings.jsx b/apps/presentationeditor/mobile/src/view/settings/ApplicationSettings.jsx index cc6a2fb22d..5936fefddb 100644 --- a/apps/presentationeditor/mobile/src/view/settings/ApplicationSettings.jsx +++ b/apps/presentationeditor/mobile/src/view/settings/ApplicationSettings.jsx @@ -19,8 +19,6 @@ const PageApplicationSettings = props => { // set mode const appOptions = props.storeAppOptions; - const currentLang = appOptions.lang; - const isRtlLang = currentLang && /^(ar)$/i.test(currentLang); const storeThemes = props.storeThemes; const colorTheme = storeThemes.colorTheme; const themes = storeThemes.themes; @@ -29,7 +27,6 @@ const PageApplicationSettings = props => { const _isEdit = appOptions.isEdit; // const _isShowMacros = (!appOptions.isDisconnected && appOptions.customization) ? appOptions.customization.macros !== false : true; - return ( @@ -68,7 +65,7 @@ const PageApplicationSettings = props => { setMacrosSettings: props.setMacrosSettings }}> - {isRtlLang && + {Common.Locale.isCurrentLangRtl && <> diff --git a/apps/spreadsheeteditor/mobile/src/index_dev.html b/apps/spreadsheeteditor/mobile/src/index_dev.html index 3a7fab6c68..22fc7f954f 100644 --- a/apps/spreadsheeteditor/mobile/src/index_dev.html +++ b/apps/spreadsheeteditor/mobile/src/index_dev.html @@ -24,6 +24,9 @@ + <% if ( htmlWebpackPlugin.options.skeleton.htmlscript ) { %> diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/ApplicationSettings.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/ApplicationSettings.jsx index dc13c3be71..064a4f7cec 100644 --- a/apps/spreadsheeteditor/mobile/src/view/settings/ApplicationSettings.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/settings/ApplicationSettings.jsx @@ -31,8 +31,6 @@ const PageApplicationSettings = props => { // set mode const appOptions = props.storeAppOptions; const storeThemes = props.storeThemes; - const currentLang = appOptions.lang; - const isRtlLang = currentLang && /^(ar)$/i.test(currentLang); const colorTheme = storeThemes.colorTheme; const themes = storeThemes.themes; const isConfigSelectTheme = storeThemes.isConfigSelectTheme; @@ -111,7 +109,7 @@ const PageApplicationSettings = props => { onChangeMacrosSettings: props.onChangeMacrosSettings }}> - {isRtlLang && + {Common.Locale.isCurrentLangRtl && <>