From 3e72de7dc1dbe4801dbcbecb995d497c028be59a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 9 Apr 2014 16:01:09 +0200 Subject: [PATCH] BUGFIX: share pop-up wasn't properly positioned when activated using keyboard --- app/assets/javascripts/discourse/views/share_view.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/views/share_view.js b/app/assets/javascripts/discourse/views/share_view.js index 44f07fb1fa3..ea406c72ef3 100644 --- a/app/assets/javascripts/discourse/views/share_view.js +++ b/app/assets/javascripts/discourse/views/share_view.js @@ -53,6 +53,7 @@ Discourse.ShareView = Discourse.View.extend({ $html.on('click.discoure-share-link', '[data-share-url]', function(e) { e.preventDefault(); var $currentTarget = $(e.currentTarget), + $currentTargetOffset = $currentTarget.offset(), $shareLink = $('#share-link'); var url = $currentTarget.data('share-url'); var postNumber = $currentTarget.data('post-number'); @@ -63,7 +64,7 @@ Discourse.ShareView = Discourse.View.extend({ } var shareLinkWidth = $shareLink.width(); - var x = e.pageX - (shareLinkWidth / 2); + var x = $currentTargetOffset.left - (shareLinkWidth / 2); if (x < 25) { x = 25; } @@ -72,9 +73,9 @@ Discourse.ShareView = Discourse.View.extend({ } var header = $('.d-header'); - var y = e.pageY - ($shareLink.height() + 20); + var y = $currentTargetOffset.top - ($shareLink.height() + 20); if (y < header.offset().top + header.height()) { - y = e.pageY + 10; + y = $currentTargetOffset.top + 10; } $shareLink.css({