Skip to content

Commit 7546a29

Browse files
committed
FIX: After sharing links and navigating long topics sometimes you'd have a lot of blank space.
1 parent 3d7e46b commit 7546a29

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

app/assets/javascripts/discourse/controllers/share_controller.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,6 @@ Discourse.ShareController = Discourse.Controller.extend({
1010

1111
needs: ['topic'],
1212

13-
// When the user clicks the post number, we pop up a share box
14-
shareLink: function(e, url) {
15-
var x;
16-
x = e.pageX - 150;
17-
if (x < 25) {
18-
x = 25;
19-
}
20-
$('#share-link').css({
21-
left: "" + x + "px",
22-
top: "" + (e.pageY - 100) + "px"
23-
});
24-
this.set('link', url);
25-
return false;
26-
},
27-
2813
// Close the share controller
2914
close: function() {
3015
this.set('link', '');

app/assets/javascripts/discourse/models/share_link.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ Discourse.ShareLink = Discourse.Model.extend({
1313
return Discourse.ShareLink.urlFor(this.get('target'), this.get('link'), this.get('topicTitle'));
1414
}.property('target', 'link', 'topicTitle'),
1515

16-
title: function() {
17-
return I18n.t("share." + this.get('target'));
18-
}.property('target'),
16+
title: Discourse.computed.i18n('target', 'share.%@'),
1917

2018
iconClass: function() {
2119
return Discourse.ShareLink.iconClasses[this.get('target')];

app/assets/javascripts/discourse/views/post_menu_view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Discourse.PostMenuView = Discourse.View.extend({
166166
// Share button
167167
renderShare: function(post, buffer) {
168168
buffer.push("<button title=\"" +
169-
(I18n.t("post.controls.share")) +
169+
I18n.t("post.controls.share") +
170170
"\" data-share-url=\"" + post.get('shareUrl') + "\" class='share'><i class=\"icon-link\"></i></button>");
171171
},
172172

app/assets/javascripts/discourse/views/share_view.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Discourse.ShareView = Discourse.View.extend({
3030
window.setTimeout(function() {
3131
$linkInput.select().focus();
3232
}, 160);
33+
} else {
34+
$('#share-link').css('top', 0);
3335
}
3436
}.observes('controller.link'),
3537

@@ -53,7 +55,17 @@ Discourse.ShareView = Discourse.View.extend({
5355
if (url.indexOf("/") === 0) {
5456
url = window.location.protocol + "//" + window.location.host + url;
5557
}
56-
shareView.get('controller').shareLink(e, url);
58+
59+
var x = e.pageX - 150;
60+
if (x < 25) {
61+
x = 25;
62+
}
63+
64+
$('#share-link').css({
65+
left: "" + x + "px",
66+
top: "" + (e.pageY - 100) + "px"
67+
});
68+
shareView.set('controller.link', url);
5769
return false;
5870
});
5971

0 commit comments

Comments
 (0)