From 684a9668bf4c1bf0115683350ab37ef742e86aa7 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Fri, 19 Aug 2022 21:41:24 +0300 Subject: [PATCH 01/42] [all] added option to turn on RTL --- apps/common/main/lib/util/htmlutils.js | 24 +++++++++++-------- .../main/app/view/FileMenuPanels.js | 14 +++++++++++ .../main/app/view/FileMenuPanels.js | 15 +++++++++++- .../main/app/view/FileMenuPanels.js | 14 +++++++++++ 4 files changed, 56 insertions(+), 11 deletions(-) diff --git a/apps/common/main/lib/util/htmlutils.js b/apps/common/main/lib/util/htmlutils.js index e2c1329ed..99e690eca 100644 --- a/apps/common/main/lib/util/htmlutils.js +++ b/apps/common/main/lib/util/htmlutils.js @@ -1,3 +1,17 @@ +var checkLocalStorage = (function () { + try { + var storage = window['localStorage']; + return true; + } + catch(e) { + return false; + } +})(); + +if ( checkLocalStorage && localStorage.getItem("ui-rtl") === '1' ) { + document.body.setAttribute('dir', 'rtl'); + document.body.classList.add('rtl'); +} function checkScaling() { var matches = { @@ -42,16 +56,6 @@ var params = (function() { return urlParams; })(); -var checkLocalStorage = (function () { - try { - var storage = window['localStorage']; - return true; - } - catch(e) { - return false; - } -})(); - if ( window.desktop ) { var theme = desktop.theme diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index eb5ab2551..f7e1de1ff 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -344,6 +344,9 @@ define([ '', '
', '', + '', + '
', + '', '', '', '', @@ -709,6 +712,14 @@ define([ })).on('click', _.bind(me.applySettings, me)); }); + this.chRTL = new Common.UI.CheckBox({ + el: $markup.findById('#fms-chb-rtl-ui'), + labelText: this.strRTLSupport, + dataHint: '2', + dataHintDirection: 'left', + dataHintOffset: 'small' + }); + this.pnlSettings = $markup.find('.flex-settings').addBack().filter('.flex-settings'); this.pnlApply = $markup.find('.fms-flex-apply').addBack().filter('.fms-flex-apply'); this.pnlTable = this.pnlSettings.find('table'); @@ -861,6 +872,7 @@ define([ } this.chDarkMode.setValue(Common.UI.Themes.isContentThemeDark()); this.chDarkMode.setDisabled(!Common.UI.Themes.isDarkTheme()); + this.chRTL.setValue(Common.localStorage.getBool("ui-rtl")); if (this.mode.canViewReview) { value = Common.Utils.InternalSettings.get("de-settings-review-hover-mode"); @@ -918,6 +930,7 @@ define([ } Common.localStorage.setItem("de-settings-paste-button", this.chPaste.isChecked() ? 1 : 0); + Common.localStorage.setBool("ui-rtl", this.chRTL.isChecked()); Common.localStorage.save(); @@ -988,6 +1001,7 @@ define([ textForceSave: 'Save to Server', textOldVersions: 'Make the files compatible with older MS Word versions when saved as DOCX', txtCacheMode: 'Default cache mode', + strRTLSupport: 'RTL interface', strMacrosSettings: 'Macros Settings', txtWarnMacros: 'Show Notification', txtRunMacros: 'Enable All', diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index bc3690f07..08ca6fcfa 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -269,7 +269,9 @@ define([ '', '
', '', - + '', + '
', + '', '', '', '', @@ -540,6 +542,14 @@ define([ dataHintOffset: 'big' }); + this.chRTL = new Common.UI.CheckBox({ + el: $markup.findById('#fms-chb-rtl-ui'), + labelText: this.strRTLSupport, + dataHint: '2', + dataHintDirection: 'left', + dataHintOffset: 'small' + }); + $markup.find('.btn.primary').each(function(index, el){ (new Common.UI.Button({ el: $(el) @@ -670,6 +680,7 @@ define([ this.lblMacrosDesc.text(item ? item.get('descValue') : this.txtWarnMacrosDesc); this.chPaste.setValue(Common.Utils.InternalSettings.get("pe-settings-paste-button")); + this.chRTL.setValue(Common.localStorage.getBool("ui-rtl")); var data = []; for (var t in Common.UI.Themes.map()) { @@ -716,6 +727,7 @@ define([ Common.Utils.InternalSettings.set("pe-macros-mode", this.cmbMacros.getValue()); Common.localStorage.setItem("pe-settings-paste-button", this.chPaste.isChecked() ? 1 : 0); + Common.localStorage.setBool("ui-rtl", this.chRTL.isChecked()); Common.localStorage.save(); @@ -768,6 +780,7 @@ define([ textForceSave: 'Save to Server', txtSpellCheck: 'Spell Checking', txtCacheMode: 'Default cache mode', + strRTLSupport: 'RTL interface', strMacrosSettings: 'Macros Settings', txtWarnMacros: 'Show Notification', txtRunMacros: 'Enable All', diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index b39b9267c..fb7ec1c32 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -244,6 +244,9 @@ define([ '', '
', '', + '', + '
', + '', '', '', '', @@ -712,6 +715,14 @@ define([ }); this.btnAutoCorrect.on('click', _.bind(this.autoCorrect, this)); + this.chRTL = new Common.UI.CheckBox({ + el: $markup.findById('#fms-chb-rtl-ui'), + labelText: this.strRTLSupport, + dataHint: '2', + dataHintDirection: 'left', + dataHintOffset: 'small' + }); + $markup.find('.btn.primary').each(function(index, el){ (new Common.UI.Button({ el: $(el) @@ -877,6 +888,7 @@ define([ this.cmbMacros.setValue(item ? item.get('value') : 0); this.chPaste.setValue(Common.Utils.InternalSettings.get("sse-settings-paste-button")); + this.chRTL.setValue(Common.localStorage.getBool("ui-rtl")); var data = []; for (var t in Common.UI.Themes.map()) { @@ -977,6 +989,7 @@ define([ Common.Utils.InternalSettings.set("sse-macros-mode", this.cmbMacros.getValue()); Common.localStorage.setItem("sse-settings-paste-button", this.chPaste.isChecked() ? 1 : 0); + Common.localStorage.setBool("ui-rtl", this.chRTL.isChecked()); Common.localStorage.save(); if (this.menu) { @@ -1103,6 +1116,7 @@ define([ strDecimalSeparator: 'Decimal separator', strThousandsSeparator: 'Thousands separator', txtCacheMode: 'Default cache mode', + strRTLSupport: 'RTL interface', strMacrosSettings: 'Macros Settings', txtWarnMacros: 'Show Notification', txtRunMacros: 'Enable All', From 7146701873230a285b9d12866bbe1735466af498 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Mon, 22 Aug 2022 14:24:38 +0300 Subject: [PATCH 02/42] [all] added flag to use RTL in code --- apps/documenteditor/main/app/controller/Main.js | 1 + apps/presentationeditor/main/app/controller/Main.js | 1 + apps/spreadsheeteditor/main/app/controller/Main.js | 1 + 3 files changed, 3 insertions(+) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index ee8d7e32b..d49d93f27 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -416,6 +416,7 @@ define([ this.appOptions.canFeatureComparison = true; this.appOptions.canFeatureContentControl = true; this.appOptions.canFeatureForms = !!this.api.asc_isSupportFeature("forms"); + this.appOptions.uiRtl = Common.localStorage.getBool("ui-rtl"); this.appOptions.mentionShare = !((typeof (this.appOptions.customization) == 'object') && (this.appOptions.customization.mentionShare==false)); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 74274bb87..d70e24a71 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -369,6 +369,7 @@ define([ this.appOptions.compatibleFeatures = (typeof (this.appOptions.customization) == 'object') && !!this.appOptions.customization.compatibleFeatures; this.appOptions.canRequestSharingSettings = this.editorConfig.canRequestSharingSettings; this.appOptions.mentionShare = !((typeof (this.appOptions.customization) == 'object') && (this.appOptions.customization.mentionShare==false)); + this.appOptions.uiRtl = Common.localStorage.getBool("ui-rtl"); this.appOptions.user.guest && this.appOptions.canRenameAnonymous && Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this)); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 4f1f37aea..9701676a0 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -415,6 +415,7 @@ define([ this.appOptions.canMakeActionLink = this.editorConfig.canMakeActionLink; this.appOptions.canFeaturePivot = true; this.appOptions.canFeatureViews = true; + this.appOptions.uiRtl = Common.localStorage.getBool("ui-rtl"); if (this.appOptions.user.guest && this.appOptions.canRenameAnonymous && !this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge && !this.appOptions.isEditOle) Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this)); From 15ce9217143420446838ac3789309332a4f45dc4 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Mon, 12 Sep 2022 22:51:29 +0300 Subject: [PATCH 03/42] [all] function to check 'isRtl' flag --- apps/common/locale.js | 7 ++++++- apps/common/main/lib/util/utils.js | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/common/locale.js b/apps/common/locale.js index db8f29318..608c33087 100644 --- a/apps/common/locale.js +++ b/apps/common/locale.js @@ -167,10 +167,15 @@ Common.Locale = new(function() { } else require(polyfills, _requireLang); } else _requireLang(); + const _isCurrentRtl = function () { + return false; + }; + return { apply: _applyLocalization, get: _get, - getCurrentLanguage: _getCurrentLanguage + getCurrentLanguage: _getCurrentLanguage, + isCurrentLanguageRtl: _isCurrentRtl }; })(); diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index 03aac86ae..645d7f3b5 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -1091,4 +1091,13 @@ Common.Utils.getKeyByValue = function(obj, value) { return prop; } } +}; + +Common.UI.isRTL = function () { + if ( window.isrtl == undefined ) { + window.isrtl = Common.localStorage.itemExists('ui-rtl') ? + Common.localStorage.getBool("ui-rtl") : Common.Locale.isCurrentLanguageRtl(); + } + + return window.isrtl; }; \ No newline at end of file From cc7248f51d7e48f83eae9235217608d70ca29b0e Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Mon, 12 Sep 2022 22:53:28 +0300 Subject: [PATCH 04/42] [rtl] fix left and right panels position for DE --- apps/common/main/resources/less/common.less | 25 ++++++++ .../main/app/controller/Viewport.js | 4 +- apps/documenteditor/main/app/view/Viewport.js | 59 +++++++++++-------- 3 files changed, 61 insertions(+), 27 deletions(-) diff --git a/apps/common/main/resources/less/common.less b/apps/common/main/resources/less/common.less index 6e37abbb4..181661900 100644 --- a/apps/common/main/resources/less/common.less +++ b/apps/common/main/resources/less/common.less @@ -51,6 +51,11 @@ label { .tool-menu-btns { border-right: @scaled-one-px-value-ie solid @border-toolbar-ie; border-right: @scaled-one-px-value solid @border-toolbar; + + .rtl & { + border-left: @scaled-one-px-value solid @border-toolbar; + border-right: 0 none; + } } } @@ -63,6 +68,14 @@ label { background-color: @background-toolbar; right: 0; overflow: hidden; + + .rtl & { + left: 0; + right: auto; + + border-right: @scaled-one-px-value solid @border-toolbar; + border-left: 0 none; + } } } } @@ -85,6 +98,13 @@ label { border-right: @scaled-one-px-value-ie solid @border-toolbar-ie; border-right: @scaled-one-px-value solid @border-toolbar; + .rtl & { + padding-right: 40px; + padding-left: 0; + border-left: @scaled-one-px-value solid @border-toolbar; + border-right: 0 none; + } + #left-panel-chat { height: 100%; } @@ -108,6 +128,11 @@ label { border-left: @scaled-one-px-value-ie solid @border-toolbar-ie; border-left: @scaled-one-px-value solid @border-toolbar; line-height: 15px; + + .rtl & { + border-right: @scaled-one-px-value solid @border-toolbar; + border-left: 0 none; + } } .statusbar { diff --git a/apps/documenteditor/main/app/controller/Viewport.js b/apps/documenteditor/main/app/controller/Viewport.js index 713133cde..ba460e46e 100644 --- a/apps/documenteditor/main/app/controller/Viewport.js +++ b/apps/documenteditor/main/app/controller/Viewport.js @@ -212,7 +212,7 @@ define([ this.viewport.hlayout.doLayout(); break; case 'history': - var panel = this.viewport.hlayout.items[1]; + var panel = this.viewport.hlayout.getItem('history'); if (panel.resize.el) { this.boxSdk.css('border-left', ''); panel.resize.el.show(); @@ -220,7 +220,7 @@ define([ this.viewport.hlayout.doLayout(); break; case 'leftmenu': - var panel = this.viewport.hlayout.items[0]; + var panel = this.viewport.hlayout.getItem('left'); if (panel.resize.el) { if (panel.el.width() > 40) { this.boxSdk.css('border-left', ''); diff --git a/apps/documenteditor/main/app/view/Viewport.js b/apps/documenteditor/main/app/view/Viewport.js index a90ad6f6b..ac07dc555 100644 --- a/apps/documenteditor/main/app/view/Viewport.js +++ b/apps/documenteditor/main/app/view/Viewport.js @@ -104,33 +104,42 @@ define([ $container = $('#viewport-hbox-layout', this.$el); var items = $container.find(' > .layout-item'); + let iarray = [{ // left menu chat & comment + el: items[0], + rely: true, + alias: 'left', + resize: { + hidden: true, + autohide: false, + min: 300, + max: 600 + }}, { // history versions + el: items[3], + rely: true, + alias: 'history', + resize: { + hidden: true, + autohide: false, + min: 300, + max: 600 + } + }, { // sdk + el: items[1], + stretch: true + }, { // right menu + el: $(items[2]).hide(), + rely: true + } + ]; + + if ( Common.UI.isRTL() ) { + [iarray[0], iarray[3]] = [iarray[3], iarray[0]]; + [iarray[1], iarray[2]] = [iarray[2], iarray[1]]; + } + this.hlayout = new Common.UI.HBoxLayout({ box: $container, - items: [{ // left menu chat & comment - el: items[0], - rely: true, - resize: { - hidden: true, - autohide: false, - min: 300, - max: 600 - }}, { // history versions - el: items[3], - rely: true, - resize: { - hidden: true, - autohide: false, - min: 300, - max: 600 - } - }, { // sdk - el: items[1], - stretch: true - }, { // right menu - el: $(items[2]).hide(), - rely: true - } - ] + items: iarray }); return this; From aa35384d5e423c322a38c016db9ec720900fccd2 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Wed, 14 Sep 2022 21:22:52 +0300 Subject: [PATCH 05/42] [rtl] Fix input and combobox components --- .../main/lib/component/ComboBorderSize.js | 4 +- apps/common/main/resources/less/buttons.less | 4 ++ .../resources/less/combo-border-size.less | 10 +++++ apps/common/main/resources/less/combobox.less | 38 +++++++++++++++++++ .../main/resources/less/dropdown-menu.less | 4 ++ apps/common/main/resources/less/input.less | 25 ++++++++++++ 6 files changed, 83 insertions(+), 2 deletions(-) diff --git a/apps/common/main/lib/component/ComboBorderSize.js b/apps/common/main/lib/component/ComboBorderSize.js index d784d0f7a..28a2f6e83 100644 --- a/apps/common/main/lib/component/ComboBorderSize.js +++ b/apps/common/main/lib/component/ComboBorderSize.js @@ -244,10 +244,10 @@ define([ '', '