FIX: After sharing links and navigating long topics sometimes you'd have a lot of blank space.
This commit is contained in:
parent
3d7e46b42a
commit
7546a29d10
|
@ -10,21 +10,6 @@ Discourse.ShareController = Discourse.Controller.extend({
|
||||||
|
|
||||||
needs: ['topic'],
|
needs: ['topic'],
|
||||||
|
|
||||||
// When the user clicks the post number, we pop up a share box
|
|
||||||
shareLink: function(e, url) {
|
|
||||||
var x;
|
|
||||||
x = e.pageX - 150;
|
|
||||||
if (x < 25) {
|
|
||||||
x = 25;
|
|
||||||
}
|
|
||||||
$('#share-link').css({
|
|
||||||
left: "" + x + "px",
|
|
||||||
top: "" + (e.pageY - 100) + "px"
|
|
||||||
});
|
|
||||||
this.set('link', url);
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Close the share controller
|
// Close the share controller
|
||||||
close: function() {
|
close: function() {
|
||||||
this.set('link', '');
|
this.set('link', '');
|
||||||
|
|
|
@ -13,9 +13,7 @@ Discourse.ShareLink = Discourse.Model.extend({
|
||||||
return Discourse.ShareLink.urlFor(this.get('target'), this.get('link'), this.get('topicTitle'));
|
return Discourse.ShareLink.urlFor(this.get('target'), this.get('link'), this.get('topicTitle'));
|
||||||
}.property('target', 'link', 'topicTitle'),
|
}.property('target', 'link', 'topicTitle'),
|
||||||
|
|
||||||
title: function() {
|
title: Discourse.computed.i18n('target', 'share.%@'),
|
||||||
return I18n.t("share." + this.get('target'));
|
|
||||||
}.property('target'),
|
|
||||||
|
|
||||||
iconClass: function() {
|
iconClass: function() {
|
||||||
return Discourse.ShareLink.iconClasses[this.get('target')];
|
return Discourse.ShareLink.iconClasses[this.get('target')];
|
||||||
|
|
|
@ -166,7 +166,7 @@ Discourse.PostMenuView = Discourse.View.extend({
|
||||||
// Share button
|
// Share button
|
||||||
renderShare: function(post, buffer) {
|
renderShare: function(post, buffer) {
|
||||||
buffer.push("<button title=\"" +
|
buffer.push("<button title=\"" +
|
||||||
(I18n.t("post.controls.share")) +
|
I18n.t("post.controls.share") +
|
||||||
"\" data-share-url=\"" + post.get('shareUrl') + "\" class='share'><i class=\"icon-link\"></i></button>");
|
"\" data-share-url=\"" + post.get('shareUrl') + "\" class='share'><i class=\"icon-link\"></i></button>");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ Discourse.ShareView = Discourse.View.extend({
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
$linkInput.select().focus();
|
$linkInput.select().focus();
|
||||||
}, 160);
|
}, 160);
|
||||||
|
} else {
|
||||||
|
$('#share-link').css('top', 0);
|
||||||
}
|
}
|
||||||
}.observes('controller.link'),
|
}.observes('controller.link'),
|
||||||
|
|
||||||
|
@ -53,7 +55,17 @@ Discourse.ShareView = Discourse.View.extend({
|
||||||
if (url.indexOf("/") === 0) {
|
if (url.indexOf("/") === 0) {
|
||||||
url = window.location.protocol + "//" + window.location.host + url;
|
url = window.location.protocol + "//" + window.location.host + url;
|
||||||
}
|
}
|
||||||
shareView.get('controller').shareLink(e, url);
|
|
||||||
|
var x = e.pageX - 150;
|
||||||
|
if (x < 25) {
|
||||||
|
x = 25;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#share-link').css({
|
||||||
|
left: "" + x + "px",
|
||||||
|
top: "" + (e.pageY - 100) + "px"
|
||||||
|
});
|
||||||
|
shareView.set('controller.link', url);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue