From 95c871be3eaf2ac8d3268a9aa25e06df705a849a Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Fri, 6 Nov 2020 09:46:26 -0600 Subject: [PATCH] DEV: Move popups left if application.hbs wrapper is moved by theme We have a div that is inside #main because of the history of Ember explained here. Once we have Ember cli, we can use optional feature flags and disable creating this div with application-template-wrapper: false, and refactor this code and any plugins that rely on that div being present (some plugin regarding remote collaboration??). --- .../javascripts/discourse/app/components/share-popup.js | 5 ++++- .../javascripts/discourse/app/mixins/card-contents-base.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/share-popup.js b/app/assets/javascripts/discourse/app/components/share-popup.js index b62f08dc2c..8fc21f5aba 100644 --- a/app/assets/javascripts/discourse/app/components/share-popup.js +++ b/app/assets/javascripts/discourse/app/components/share-popup.js @@ -69,7 +69,10 @@ export default Component.extend({ } const shareLinkWidth = $this.width(); - let x = $currentTargetOffset.left - shareLinkWidth / 2; + const pageLeftOffset = document.querySelector( + ".ember-application > .ember-view" + ).offsetLeft; + let x = $currentTargetOffset.left - pageLeftOffset - shareLinkWidth / 2; if (x < 25) { x = 25; } diff --git a/app/assets/javascripts/discourse/app/mixins/card-contents-base.js b/app/assets/javascripts/discourse/app/mixins/card-contents-base.js index cccf26db7e..5e07400d0a 100644 --- a/app/assets/javascripts/discourse/app/mixins/card-contents-base.js +++ b/app/assets/javascripts/discourse/app/mixins/card-contents-base.js @@ -201,7 +201,10 @@ export default Mixin.create({ } } else { // The site direction is ltr - position.left += target.width() + 10; + const pageLeftOffset = document.querySelector( + ".ember-application > .ember-view" + ).offsetLeft; + position.left += target.width() - pageLeftOffset + 10; let overage = $(window).width() - 50 - (position.left + width); if (overage < 0) {