From f4aacf70306c32d313758b36c29999980b57b39d Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Tue, 12 Jul 2022 10:41:09 +0300 Subject: [PATCH] [mobile] fix bug 57560 --- apps/common/mobile/utils/htmlutils.js | 16 ++++++++++++++++ apps/documenteditor/mobile/src/app.js | 7 ------- apps/presentationeditor/mobile/src/app.js | 4 ---- apps/spreadsheeteditor/mobile/src/app.js | 7 ------- vendor/framework7-react/build/webpack.config.js | 8 ++++++++ 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/apps/common/mobile/utils/htmlutils.js b/apps/common/mobile/utils/htmlutils.js index dd3f690b4..af2eaaca4 100644 --- a/apps/common/mobile/utils/htmlutils.js +++ b/apps/common/mobile/utils/htmlutils.js @@ -7,3 +7,19 @@ if ( !obj ) { } document.body.classList.add(`theme-type-${obj.type}`); + +const load_stylesheet = reflink => { + let link = document.createElement( "link" ); + link.href = reflink; + link.type = "text/css"; + link.rel = "stylesheet"; + + document.getElementsByTagName("head")[0].appendChild(link); +}; + +if ( !localStorage && localStorage.getItem('mode-direction') === 'rtl' ) { + document.body.classList.add('rtl'); + load_stylesheet('./css/framework7-rtl.css') +} else { + load_stylesheet('./css/framework7.css') +} diff --git a/apps/documenteditor/mobile/src/app.js b/apps/documenteditor/mobile/src/app.js index 49535c3a4..69b8ca7a6 100644 --- a/apps/documenteditor/mobile/src/app.js +++ b/apps/documenteditor/mobile/src/app.js @@ -16,13 +16,6 @@ window.$ = jQuery; // Import Framework7 Styles -const htmlElem = document.querySelector('html'); -const direction = LocalStorage.getItem('mode-direction'); - -direction === 'rtl' ? htmlElem.setAttribute('dir', 'rtl') : htmlElem.setAttribute('dir', 'ltr'); - -import(`framework7/framework7-bundle${direction === 'rtl' ? '-rtl' : ''}.css`); - // Import Icons and App Custom Styles // import '../css/icons.css'; import('./less/app.less'); diff --git a/apps/presentationeditor/mobile/src/app.js b/apps/presentationeditor/mobile/src/app.js index 7887217f5..9a084c619 100644 --- a/apps/presentationeditor/mobile/src/app.js +++ b/apps/presentationeditor/mobile/src/app.js @@ -15,10 +15,6 @@ window.jQuery = jQuery; window.$ = jQuery; // Import Framework7 or Framework7-RTL Styles -let direction = LocalStorage.getItem('mode-direction'); - -direction === 'rtl' ? $$('html').attr('dir', 'rtl') : $$('html').removeAttr('dir') -import(`framework7/framework7-bundle${direction === 'rtl' ? '-rtl' : ''}.css`) // Import App Custom Styles import('./less/app.less'); diff --git a/apps/spreadsheeteditor/mobile/src/app.js b/apps/spreadsheeteditor/mobile/src/app.js index df2cc1447..fb100c1a6 100644 --- a/apps/spreadsheeteditor/mobile/src/app.js +++ b/apps/spreadsheeteditor/mobile/src/app.js @@ -16,13 +16,6 @@ window.$ = jQuery; // Import Framework7 Styles -const htmlElem = document.querySelector('html'); -const direction = LocalStorage.getItem('mode-direction'); - -direction === 'rtl' ? htmlElem.setAttribute('dir', 'rtl') : htmlElem.setAttribute('dir', 'ltr'); - -import(`framework7/framework7-bundle${direction === 'rtl' ? '-rtl' : ''}.css`); - // Import App Custom Styles import('./less/app.less'); diff --git a/vendor/framework7-react/build/webpack.config.js b/vendor/framework7-react/build/webpack.config.js index aa3fbaf54..ec3d574cb 100644 --- a/vendor/framework7-react/build/webpack.config.js +++ b/vendor/framework7-react/build/webpack.config.js @@ -231,6 +231,14 @@ module.exports = { }), new CopyWebpackPlugin({ patterns: [ + { + from: resolvePath('node_modules/framework7/framework7-bundle.css'), + to: `../../${editor}/mobile/css/framework7.css`, + }, + { + from: resolvePath('node_modules/framework7/framework7-bundle-rtl.css'), + to: `../../${editor}/mobile/css/framework7-rtl.css`, + }, { noErrorOnMissing: true, from: resolvePath('src/static'),