mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Merge pull request #3557 from scossar/rtl-usercard
FIX: positioning of usercard in rtl layouts
This commit is contained in:
commit
a0e8bc2492
1 changed files with 18 additions and 5 deletions
|
@ -84,18 +84,31 @@ export default Discourse.View.extend(CleansUp, {
|
||||||
},
|
},
|
||||||
|
|
||||||
_willShow(target) {
|
_willShow(target) {
|
||||||
|
const rtl = ($('html').css('direction')) === 'rtl';
|
||||||
if (!target) { return; }
|
if (!target) { return; }
|
||||||
const width = this.$().width();
|
const width = this.$().width();
|
||||||
|
|
||||||
Ember.run.schedule('afterRender', () => {
|
Ember.run.schedule('afterRender', () => {
|
||||||
if (target) {
|
if (target) {
|
||||||
let position = target.offset();
|
let position = target.offset();
|
||||||
if (position) {
|
if (position) {
|
||||||
position.left += target.width() + 10;
|
|
||||||
|
|
||||||
const overage = ($(window).width() - 50) - (position.left + width);
|
if (rtl) { // The site direction is rtl
|
||||||
if (overage < 0) {
|
position.right = $(window).width() - position.left + 10;
|
||||||
position.left += overage;
|
position.left = 'auto';
|
||||||
position.top += target.height() + 48;
|
let overage = ($(window).width() - 50) - (position.right + width);
|
||||||
|
if (overage < 0) {
|
||||||
|
position.right += overage;
|
||||||
|
position.top += target.height() + 48;
|
||||||
|
}
|
||||||
|
} else { // The site direction is ltr
|
||||||
|
position.left += target.width() + 10;
|
||||||
|
|
||||||
|
let overage = ($(window).width() - 50) - (position.left + width);
|
||||||
|
if (overage < 0) {
|
||||||
|
position.left += overage;
|
||||||
|
position.top += target.height() + 48;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
position.top -= $('#main-outlet').offset().top;
|
position.top -= $('#main-outlet').offset().top;
|
||||||
|
|
Loading…
Reference in a new issue