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