From 1bdf43d5cc7df0543ddac20686a0ddc351a2f125 Mon Sep 17 00:00:00 2001 From: Simon Cossar Date: Thu, 18 Jun 2015 19:28:02 -0700 Subject: [PATCH] Correct user-card positioning for rtl layouts --- .../discourse/views/user-card.js.es6 | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/views/user-card.js.es6 b/app/assets/javascripts/discourse/views/user-card.js.es6 index bdc35d5438f..2e3fe8f3ea3 100644 --- a/app/assets/javascripts/discourse/views/user-card.js.es6 +++ b/app/assets/javascripts/discourse/views/user-card.js.es6 @@ -84,18 +84,32 @@ export default Discourse.View.extend(CleansUp, { }, _willShow(target) { + //const direction = $('html').css('direction'); if (!target) { return; } const width = this.$().width(); + Ember.run.schedule('afterRender', () => { if (target) { let position = target.offset(); if (position) { - position.left += target.width() + 10; - const overage = ($(window).width() - 50) - (position.left + width); - if (overage < 0) { - position.left += overage; - position.top += target.height() + 48; + // Check for a right to left layout + if (($('html').css('direction')) === 'rtl') { + position.right = $(window).width() - position.left + 10; + position.left = 'auto'; + const 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; + + const overage = ($(window).width() - 50) - (position.left + width); + if (overage < 0) { + position.left += overage; + position.top += target.height() + 48; + } } position.top -= $('#main-outlet').offset().top;