FIX: Don't show quote controls when the post id is missing.

This commit is contained in:
Robin Ward 2014-04-25 15:40:48 -04:00
parent 47d000edcc
commit b91c70cac3
1 changed files with 15 additions and 13 deletions

View File

@ -64,9 +64,9 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
repliesShown: Em.computed.gt('post.replies.length', 0), repliesShown: Em.computed.gt('post.replies.length', 0),
updateQuoteElements: function($aside, desc) { updateQuoteElements: function($aside, desc) {
var navLink = ""; var navLink = "",
var quoteTitle = I18n.t("post.follow_quote"); quoteTitle = I18n.t("post.follow_quote"),
var postNumber = $aside.data('post'); postNumber = $aside.data('post');
if (postNumber) { if (postNumber) {
@ -94,7 +94,7 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
expandContract = "<i class='fa fa-" + desc + "' title='" + I18n.t("post.expand_collapse") + "'></i>"; expandContract = "<i class='fa fa-" + desc + "' title='" + I18n.t("post.expand_collapse") + "'></i>";
$aside.css('cursor', 'pointer'); $aside.css('cursor', 'pointer');
} }
$('.quote-controls', $aside).html("" + expandContract + navLink); $('.quote-controls', $aside).html(expandContract + navLink);
}, },
toggleQuote: function($aside) { toggleQuote: function($aside) {
@ -189,16 +189,18 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
var self = this; var self = this;
return this.$('aside.quote').each(function(i, e) { return this.$('aside.quote').each(function(i, e) {
var $aside = $(e); var $aside = $(e);
self.updateQuoteElements($aside, 'chevron-down'); if ($aside.data('post')) {
var $title = $('.title', $aside); self.updateQuoteElements($aside, 'chevron-down');
var $title = $('.title', $aside);
// Unless it's a full quote, allow click to expand // Unless it's a full quote, allow click to expand
if (!($aside.data('full') || $title.data('has-quote-controls'))) { if (!($aside.data('full') || $title.data('has-quote-controls'))) {
$title.on('click', function(e) { $title.on('click', function(e) {
if ($(e.target).is('a')) return true; if ($(e.target).is('a')) return true;
self.toggleQuote($aside); self.toggleQuote($aside);
}); });
$title.data('has-quote-controls', true); $title.data('has-quote-controls', true);
}
} }
}); });
}, },