BUGFIX: share pop-up wasn't properly positioned when activated using keyboard

This commit is contained in:
Régis Hanol 2014-04-09 16:01:09 +02:00
parent 863a099783
commit 3e72de7dc1

View File

@ -53,6 +53,7 @@ Discourse.ShareView = Discourse.View.extend({
$html.on('click.discoure-share-link', '[data-share-url]', function(e) { $html.on('click.discoure-share-link', '[data-share-url]', function(e) {
e.preventDefault(); e.preventDefault();
var $currentTarget = $(e.currentTarget), var $currentTarget = $(e.currentTarget),
$currentTargetOffset = $currentTarget.offset(),
$shareLink = $('#share-link'); $shareLink = $('#share-link');
var url = $currentTarget.data('share-url'); var url = $currentTarget.data('share-url');
var postNumber = $currentTarget.data('post-number'); var postNumber = $currentTarget.data('post-number');
@ -63,7 +64,7 @@ Discourse.ShareView = Discourse.View.extend({
} }
var shareLinkWidth = $shareLink.width(); var shareLinkWidth = $shareLink.width();
var x = e.pageX - (shareLinkWidth / 2); var x = $currentTargetOffset.left - (shareLinkWidth / 2);
if (x < 25) { if (x < 25) {
x = 25; x = 25;
} }
@ -72,9 +73,9 @@ Discourse.ShareView = Discourse.View.extend({
} }
var header = $('.d-header'); 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()) { if (y < header.offset().top + header.height()) {
y = e.pageY + 10; y = $currentTargetOffset.top + 10;
} }
$shareLink.css({ $shareLink.css({