mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 19:08:10 -05:00
Prevent quote content collisions with multiples in one post
[Fixes #142]
This commit is contained in:
parent
c123e40638
commit
02f29cd43f
1 changed files with 7 additions and 8 deletions
|
@ -175,14 +175,13 @@ Discourse.PostView = Discourse.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleQuote: function($aside) {
|
toggleQuote: function($aside) {
|
||||||
var $blockQuote, originalText, post, topic_id,
|
var $blockQuote, originalText, post, topic_id;
|
||||||
_this = this;
|
$aside.data('expanded',!$aside.data('expanded'));
|
||||||
this.toggleProperty('quoteExpanded');
|
if ($aside.data('expanded')) {
|
||||||
if (this.get('quoteExpanded')) {
|
|
||||||
this.updateQuoteElements($aside, 'chevron-up');
|
this.updateQuoteElements($aside, 'chevron-up');
|
||||||
// Show expanded quote
|
// Show expanded quote
|
||||||
$blockQuote = $('blockquote', $aside);
|
$blockQuote = $('blockquote', $aside);
|
||||||
this.originalContents = $blockQuote.html();
|
$aside.data('original-contents',$blockQuote.html());
|
||||||
originalText = $blockQuote.text().trim();
|
originalText = $blockQuote.text().trim();
|
||||||
$blockQuote.html(Em.String.i18n("loading"));
|
$blockQuote.html(Em.String.i18n("loading"));
|
||||||
post = this.get('post');
|
post = this.get('post');
|
||||||
|
@ -191,15 +190,14 @@ Discourse.PostView = Discourse.View.extend({
|
||||||
topic_id = $aside.data('topic');
|
topic_id = $aside.data('topic');
|
||||||
}
|
}
|
||||||
$.getJSON("/posts/by_number/" + topic_id + "/" + ($aside.data('post')), function(result) {
|
$.getJSON("/posts/by_number/" + topic_id + "/" + ($aside.data('post')), function(result) {
|
||||||
var parsed;
|
var parsed = $(result.cooked);
|
||||||
parsed = $(result.cooked);
|
|
||||||
parsed.replaceText(originalText, "<span class='highlighted'>" + originalText + "</span>");
|
parsed.replaceText(originalText, "<span class='highlighted'>" + originalText + "</span>");
|
||||||
return $blockQuote.showHtml(parsed);
|
return $blockQuote.showHtml(parsed);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Hide expanded quote
|
// Hide expanded quote
|
||||||
this.updateQuoteElements($aside, 'chevron-down');
|
this.updateQuoteElements($aside, 'chevron-down');
|
||||||
$('blockquote', $aside).showHtml(this.originalContents);
|
$('blockquote', $aside).showHtml($aside.data('original-contents'));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
@ -236,6 +234,7 @@ Discourse.PostView = Discourse.View.extend({
|
||||||
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')) {
|
if ($(e.target).is('a')) {
|
||||||
|
// if we clicked on a link, follow it
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return _this.toggleQuote($aside);
|
return _this.toggleQuote($aside);
|
||||||
|
|
Loading…
Reference in a new issue