Merge pull request #1524 from diminutivesloop/share-view-fix

FIX: prevent share-view being clipped at viewport bounds
This commit is contained in:
Robin Ward 2013-10-15 07:08:38 -07:00
commit e0e79cae73
1 changed files with 12 additions and 2 deletions

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);