From 2ea6a61a171ce1a4a85414788ebaccf5a517803e Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 6 Sep 2013 17:34:31 -0400 Subject: [PATCH] Show post number in the share dialog --- .../javascripts/discourse/controllers/share_controller.js | 1 + app/assets/javascripts/discourse/views/post_menu_view.js | 3 ++- app/assets/javascripts/discourse/views/share_view.js | 6 ++++-- config/locales/client.en.yml | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/share_controller.js b/app/assets/javascripts/discourse/controllers/share_controller.js index 2007c8bfb35..4d513b3f039 100644 --- a/app/assets/javascripts/discourse/controllers/share_controller.js +++ b/app/assets/javascripts/discourse/controllers/share_controller.js @@ -13,6 +13,7 @@ Discourse.ShareController = Discourse.Controller.extend({ // Close the share controller close: function() { this.set('link', ''); + this.set('postNumber', ''); return false; }, diff --git a/app/assets/javascripts/discourse/views/post_menu_view.js b/app/assets/javascripts/discourse/views/post_menu_view.js index f740a9ffe13..06c461363a3 100644 --- a/app/assets/javascripts/discourse/views/post_menu_view.js +++ b/app/assets/javascripts/discourse/views/post_menu_view.js @@ -167,7 +167,8 @@ Discourse.PostMenuView = Discourse.View.extend({ renderShare: function(post, buffer) { buffer.push(""); + "\" data-share-url=\"" + post.get('shareUrl') + "\" data-post-number=\"" + post.get('post_number') + + "\" class='share'>"); }, // Reply button diff --git a/app/assets/javascripts/discourse/views/share_view.js b/app/assets/javascripts/discourse/views/share_view.js index 02f4cf7ab57..2a313d51d1e 100644 --- a/app/assets/javascripts/discourse/views/share_view.js +++ b/app/assets/javascripts/discourse/views/share_view.js @@ -13,8 +13,8 @@ Discourse.ShareView = Discourse.View.extend({ title: function() { if (this.get('controller.type') === 'topic') return I18n.t('share.topic'); - return I18n.t('share.post'); - }.property('controller.type'), + return I18n.t('share.post', {postNumber: this.get('controller.postNumber')}); + }.property('controller.type', 'controller.postNumber'), hasLink: function() { if (this.present('controller.link')) return 'visible'; @@ -48,6 +48,7 @@ Discourse.ShareView = Discourse.View.extend({ e.preventDefault(); var $currentTarget = $(e.currentTarget); var url = $currentTarget.data('share-url'); + var postNumber = $currentTarget.data('post-number'); // Relative urls if (url.indexOf("/") === 0) { @@ -64,6 +65,7 @@ Discourse.ShareView = Discourse.View.extend({ top: "" + (e.pageY - 100) + "px" }); shareView.set('controller.link', url); + shareView.set('controller.postNumber', postNumber); return false; }); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index d2e8dc905ad..a255634273e 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -71,7 +71,7 @@ en: other: "%{count} days ago" share: topic: 'share a link to this topic' - post: 'share a link to this post' + post: 'share a link to post #%{postNumber}' close: 'close' twitter: 'share this link on Twitter' facebook: 'share this link on Facebook'