From 2db8a58b49207fdb5810b41ba63e119926386b11 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Sat, 10 Dec 2022 23:36:26 +0300 Subject: [PATCH] [rtl] Make display/hide more button in toolbar --- apps/common/main/lib/component/Mixtbar.js | 279 ++++++++++++++++++- apps/common/main/resources/less/toolbar.less | 30 ++ 2 files changed, 297 insertions(+), 12 deletions(-) diff --git a/apps/common/main/lib/component/Mixtbar.js b/apps/common/main/lib/component/Mixtbar.js index 0361f6c1d..5d8527755 100644 --- a/apps/common/main/lib/component/Mixtbar.js +++ b/apps/common/main/lib/component/Mixtbar.js @@ -403,7 +403,7 @@ define([ me.setMoreButton($active.attr('data-tab'), $active); } if ( !_rightedge ) { - _rightedge = $active.get(0).getBoundingClientRect().right; + _rightedge = Common.UI.isRTL() ? $active.get(0).getBoundingClientRect().left : $active.get(0).getBoundingClientRect().right; } if ( !_btns ) { _btns = []; @@ -421,12 +421,12 @@ define([ data.flex = _flex; } - if ( (_rightedge > _maxright)) { + if ( (Common.UI.isRTL() && _rightedge < 0) || (_rightedge > _maxright)) { if (!more_section.is(':visible') ) { if (_flex.length>0) { for (var i=0; i<_flex.length; i++) { var item = _flex[i].el; - _rightedge = $active.get(0).getBoundingClientRect().right; + _rightedge = Common.UI.isRTL() ? $active.get(0).getBoundingClientRect().left : $active.get(0).getBoundingClientRect().right; if (item.outerWidth() > parseInt(item.css('min-width'))) { data.rightedge = _rightedge; return; @@ -438,8 +438,8 @@ define([ var btn = _btns[i]; if ( !btn.hasClass('compactwidth') && !btn.hasClass('slot-btn-more')) { btn.addClass('compactwidth'); - _rightedge = $active.get(0).getBoundingClientRect().right; - if (_rightedge <= _maxright) + _rightedge = Common.UI.isRTL() ? $active.get(0).getBoundingClientRect().left : $active.get(0).getBoundingClientRect().right; + if ((Common.UI.isRTL() && _rightedge >= 0) || (_rightedge <= _maxright)) break; } } @@ -453,10 +453,10 @@ define([ var btn = _btns[i]; if ( btn.hasClass('compactwidth') ) { btn.removeClass('compactwidth'); - _rightedge = $active.get(0).getBoundingClientRect().right; - if ( _rightedge > _maxright) { + _rightedge = Common.UI.isRTL() ? $active.get(0).getBoundingClientRect().left : $active.get(0).getBoundingClientRect().right; + if ( (Common.UI.isRTL() && _rightedge < 0) || (_rightedge > _maxright)) { btn.addClass('compactwidth'); - _rightedge = $active.get(0).getBoundingClientRect().right; + _rightedge = Common.UI.isRTL() ? $active.get(0).getBoundingClientRect().left : $active.get(0).getBoundingClientRect().right; break; } } @@ -466,7 +466,7 @@ define([ for (var i=0; i<_flex.length; i++) { var item = _flex[i]; item.el.css('width', item.width); - data.rightedge = $active.get(0).getBoundingClientRect().right; + data.rightedge = Common.UI.isRTL() ? $active.get(0).getBoundingClientRect().left : $active.get(0).getBoundingClientRect().right; } } } @@ -506,7 +506,7 @@ define([ var me = this; if (!btnsMore[tab]) { var top = panel.position().top; - var box = $(''); + last_group.addClass(items[i].className); + var attrs = items[i].attributes; + for (var k = 0; k < attrs.length; k++) { + last_group.attr(attrs[k].name, attrs[k].value); + } + if (last_group.hasClass('flex')) { // need to update flex groups list + $active.data().flex = null; + } + more_section.before(last_group); + if (last_separator) { + last_separator.css('display', ''); + last_separator.removeAttr('hidden-on-resize'); + } + } + last_group.append(child); + hideAllMenus = true; + } else { + need_break = true; + break; + } + } + } + if (item.children().length<1) { // all buttons are moved + item.remove(); + last_group && last_group.removeAttr('group-state').attr('inner-width', item.attr('inner-width')); + last_group = null; + if (this.$moreBar.children().filter('.group').length == 0) { + this.hideMoreBtns(); + more_section.css('display', "none"); + } + } else { + last_group && last_group.attr('group-state', 'open') && item.attr('group-state', 'open'); + } + if (need_break) + break; + } else { + break; + } + last_separator = null; last_width = 0; + } else if (item.hasClass('separator')) { + more_section.before(item); + item.css('display', 'none'); + item.attr('hidden-on-resize', true); + last_separator = item; + last_width = parseInt(last_separator.css('margin-left')) + parseInt(last_separator.css('margin-right')) + 1; + hideAllMenus = true; + } + } + } else { + this.hideMoreBtns(); + more_section.css('display', "none"); + } + } + hideAllMenus && Common.UI.Menu.Manager.hideAll(); + }, + onMoreHide: function(btn, e) { var moreContainer = btn.panel.parent(); if (btn.pressed) { @@ -809,7 +1063,8 @@ define([ right = Common.Utils.innerWidth() - (showxy.left - parentxy.left + target.width()), top = showxy.top - parentxy.top + target.height() + 10; - moreContainer.css({right: right, left: 'auto', top : top, 'max-width': Common.Utils.innerWidth() + 'px'}); + var styles = Common.UI.isRTL() ? {left: '6px', right: 'auto', top : top, 'max-width': Common.Utils.innerWidth() + 'px'} : {right: right, left: 'auto', top : top, 'max-width': Common.Utils.innerWidth() + 'px'} + moreContainer.css(styles); moreContainer.show(); }, diff --git a/apps/common/main/resources/less/toolbar.less b/apps/common/main/resources/less/toolbar.less index fba1fd987..b86a58eb6 100644 --- a/apps/common/main/resources/less/toolbar.less +++ b/apps/common/main/resources/less/toolbar.less @@ -250,6 +250,9 @@ padding: 12px 10px 7px 0; border-radius: 0; z-index:999; + .rtl & { + padding: 12px 0 7px 10px; + } .compactwidth { .btn-group, .btn-toolbar { &.x-huge { @@ -285,6 +288,18 @@ .more-box { background-color: @background-toolbar-ie; background-color: @background-toolbar; + position: absolute; + right: 0; + padding-left: 12px; + padding-right: 6px; + display: none; + + .rtl & { + right: unset; + left: 0; + padding-left: 6px; + padding-right: 12px; + } } background-color: @background-toolbar-ie; @@ -301,11 +316,26 @@ padding-left: 6px; font-size: 0; + .rtl & { + padding-left: 0; + padding-right: 6px; + } + &.small { padding-left: 10px; + .rtl & { + padding-left: 0; + padding-right: 10px; + } + + .separator:not(.invisible) { margin-left: 10px; + + .rtl & { + margin-left: 0; + margin-right: 10px; + } } }