Show post number in the share dialog

This commit is contained in:
Neil Lalonde 2013-09-06 17:34:31 -04:00
parent 10547848f0
commit 2ea6a61a17
4 changed files with 8 additions and 4 deletions

View File

@ -13,6 +13,7 @@ Discourse.ShareController = Discourse.Controller.extend({
// Close the share controller // Close the share controller
close: function() { close: function() {
this.set('link', ''); this.set('link', '');
this.set('postNumber', '');
return false; return false;
}, },

View File

@ -167,7 +167,8 @@ Discourse.PostMenuView = Discourse.View.extend({
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') + "\" data-post-number=\"" + post.get('post_number') +
"\" class='share'><i class=\"icon-link\"></i></button>");
}, },
// Reply button // Reply button

View File

@ -13,8 +13,8 @@ Discourse.ShareView = Discourse.View.extend({
title: function() { title: function() {
if (this.get('controller.type') === 'topic') return I18n.t('share.topic'); if (this.get('controller.type') === 'topic') return I18n.t('share.topic');
return I18n.t('share.post'); return I18n.t('share.post', {postNumber: this.get('controller.postNumber')});
}.property('controller.type'), }.property('controller.type', 'controller.postNumber'),
hasLink: function() { hasLink: function() {
if (this.present('controller.link')) return 'visible'; if (this.present('controller.link')) return 'visible';
@ -48,6 +48,7 @@ Discourse.ShareView = Discourse.View.extend({
e.preventDefault(); e.preventDefault();
var $currentTarget = $(e.currentTarget); var $currentTarget = $(e.currentTarget);
var url = $currentTarget.data('share-url'); var url = $currentTarget.data('share-url');
var postNumber = $currentTarget.data('post-number');
// Relative urls // Relative urls
if (url.indexOf("/") === 0) { if (url.indexOf("/") === 0) {
@ -64,6 +65,7 @@ Discourse.ShareView = Discourse.View.extend({
top: "" + (e.pageY - 100) + "px" top: "" + (e.pageY - 100) + "px"
}); });
shareView.set('controller.link', url); shareView.set('controller.link', url);
shareView.set('controller.postNumber', postNumber);
return false; return false;
}); });

View File

@ -71,7 +71,7 @@ en:
other: "%{count} days ago" other: "%{count} days ago"
share: share:
topic: 'share a link to this topic' topic: 'share a link to this topic'
post: 'share a link to this post' post: 'share a link to post #%{postNumber}'
close: 'close' close: 'close'
twitter: 'share this link on Twitter' twitter: 'share this link on Twitter'
facebook: 'share this link on Facebook' facebook: 'share this link on Facebook'