prevent share-view being clipped at viewport bounds

This commit is contained in:
Nathaniel Palmer 2013-10-12 00:38:57 -04:00
parent d55dc3dd99
commit 20ab14e1b8

View File

@ -60,14 +60,24 @@ Discourse.ShareView = Discourse.View.extend({
url = window.location.protocol + "//" + window.location.host + url;
}
var x = e.pageX - 150;
var shareLinkWidth = $('#share-link').width();
var x = e.pageX - (shareLinkWidth / 2);
if (x < 25) {
x = 25;
}
if (x + shareLinkWidth > $(window).width()) {
x -= shareLinkWidth / 2;
}
var header = $('.d-header');
var y = e.pageY - ($('#share-link').height() + 20);
if (y < header.offset().top + header.height()) {
y = e.pageY + 10;
}
$('#share-link').css({
left: "" + x + "px",
top: "" + (e.pageY - 100) + "px"
top: "" + y + "px"
});
shareView.set('controller.link', url);
shareView.set('controller.postNumber', postNumber);