mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 04:52:45 +08:00
Some vars are consts
This commit is contained in:
parent
381784ea62
commit
b0238dc0ce
|
@ -1,6 +1,6 @@
|
|||
var DAY = 60 * 50 * 1000;
|
||||
const DAY = 60 * 50 * 1000;
|
||||
|
||||
var PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
||||
const PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
||||
classNames: ['topic-post', 'clearfix'],
|
||||
templateName: 'post',
|
||||
classNameBindings: ['postTypeClass',
|
||||
|
@ -14,11 +14,11 @@ var PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
|||
post: Ember.computed.alias('content'),
|
||||
|
||||
historyHeat: function() {
|
||||
var updatedAt = this.get('post.updated_at');
|
||||
const updatedAt = this.get('post.updated_at');
|
||||
if (!updatedAt) { return; }
|
||||
|
||||
// Show heat on age
|
||||
var rightNow = new Date().getTime(),
|
||||
const rightNow = new Date().getTime(),
|
||||
updatedAtDate = new Date(updatedAt).getTime();
|
||||
|
||||
if (updatedAtDate > (rightNow - DAY * Discourse.SiteSettings.history_hours_low)) return 'heatmap-high';
|
||||
|
@ -31,7 +31,7 @@ var PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
|||
}.property('post.post_type'),
|
||||
|
||||
groupNameClass: function() {
|
||||
var primaryGroupName = this.get('post.primary_group_name');
|
||||
const primaryGroupName = this.get('post.primary_group_name');
|
||||
if (primaryGroupName) {
|
||||
return "group-" + primaryGroupName;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ var PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
|||
showExpandButton: function() {
|
||||
if (this.get('controller.firstPostExpanded')) { return false; }
|
||||
|
||||
var post = this.get('post');
|
||||
const post = this.get('post');
|
||||
return post.get('post_number') === 1 && post.get('topic.expandable_first_post');
|
||||
}.property('post.post_number', 'controller.firstPostExpanded'),
|
||||
|
||||
|
@ -76,14 +76,14 @@ var PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
|||
repliesShown: Em.computed.gt('post.replies.length', 0),
|
||||
|
||||
_updateQuoteElements($aside, desc) {
|
||||
var navLink = "",
|
||||
quoteTitle = I18n.t("post.follow_quote"),
|
||||
postNumber = $aside.data('post');
|
||||
let navLink = "";
|
||||
const quoteTitle = I18n.t("post.follow_quote"),
|
||||
postNumber = $aside.data('post');
|
||||
|
||||
if (postNumber) {
|
||||
|
||||
// If we have a topic reference
|
||||
var topicId, topic;
|
||||
let topicId, topic;
|
||||
if (topicId = $aside.data('topic')) {
|
||||
topic = this.get('controller.content');
|
||||
|
||||
|
@ -101,7 +101,7 @@ var PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
|||
}
|
||||
}
|
||||
// Only add the expand/contract control if it's not a full post
|
||||
var expandContract = "";
|
||||
let expandContract = "";
|
||||
if (!$aside.data('full')) {
|
||||
expandContract = "<i class='fa fa-" + desc + "' title='" + I18n.t("post.expand_collapse") + "'></i>";
|
||||
$('.title', $aside).css('cursor', 'pointer');
|
||||
|
@ -115,7 +115,7 @@ var PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
|||
|
||||
$aside.data('expanded', !$aside.data('expanded'));
|
||||
|
||||
var self = this,
|
||||
const self = this,
|
||||
finished = function() {
|
||||
self.set('expanding', false);
|
||||
};
|
||||
|
@ -123,23 +123,23 @@ var PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
|||
if ($aside.data('expanded')) {
|
||||
this._updateQuoteElements($aside, 'chevron-up');
|
||||
// Show expanded quote
|
||||
var $blockQuote = $('blockquote', $aside);
|
||||
const $blockQuote = $('blockquote', $aside);
|
||||
$aside.data('original-contents',$blockQuote.html());
|
||||
|
||||
var originalText = $blockQuote.text().trim();
|
||||
const originalText = $blockQuote.text().trim();
|
||||
$blockQuote.html(I18n.t("loading"));
|
||||
var topicId = this.get('post.topic_id');
|
||||
let topicId = this.get('post.topic_id');
|
||||
if ($aside.data('topic')) {
|
||||
topicId = $aside.data('topic');
|
||||
}
|
||||
|
||||
var postId = parseInt($aside.data('post'), 10);
|
||||
const postId = parseInt($aside.data('post'), 10);
|
||||
topicId = parseInt(topicId, 10);
|
||||
|
||||
Discourse.ajax("/posts/by_number/" + topicId + "/" + postId).then(function (result) {
|
||||
// slightly double escape the cooked html to prevent jQuery from unescaping it
|
||||
var escaped = result.cooked.replace("&", "&");
|
||||
var parsed = $(escaped);
|
||||
const escaped = result.cooked.replace("&", "&");
|
||||
const parsed = $(escaped);
|
||||
parsed.replaceText(originalText, "<span class='highlighted'>" + originalText + "</span>");
|
||||
$blockQuote.showHtml(parsed, 'fast', finished);
|
||||
});
|
||||
|
@ -185,7 +185,7 @@ var PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
|||
// Toggle the replies this post is a reply to
|
||||
toggleReplyHistory(post) {
|
||||
|
||||
var replyHistory = post.get('replyHistory'),
|
||||
const replyHistory = post.get('replyHistory'),
|
||||
topicController = this.get('controller'),
|
||||
origScrollTop = $(window).scrollTop(),
|
||||
replyPostNumber = this.get('post.reply_to_post_number'),
|
||||
|
@ -197,8 +197,8 @@ var PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
|||
return;
|
||||
}
|
||||
|
||||
var stream = topicController.get('postStream');
|
||||
var offsetFromTop = this.$().position().top - $(window).scrollTop();
|
||||
const stream = topicController.get('postStream');
|
||||
const offsetFromTop = this.$().position().top - $(window).scrollTop();
|
||||
|
||||
if(Discourse.SiteSettings.experimental_reply_expansion) {
|
||||
if(postNumber - replyPostNumber > 1) {
|
||||
|
@ -213,7 +213,7 @@ var PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
|||
}
|
||||
|
||||
if (replyHistory.length > 0) {
|
||||
var origHeight = this.$('.embedded-posts.top').height();
|
||||
const origHeight = this.$('.embedded-posts.top').height();
|
||||
|
||||
replyHistory.clear();
|
||||
Em.run.next(function() {
|
||||
|
@ -235,17 +235,17 @@ var PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
|||
|
||||
// Add the quote controls to a post
|
||||
_insertQuoteControls() {
|
||||
var self = this,
|
||||
const self = this,
|
||||
$quotes = this.$('aside.quote');
|
||||
|
||||
// Safety check - in some cases with cloackedView this seems to be `undefined`.
|
||||
if (Em.isEmpty($quotes)) { return; }
|
||||
|
||||
$quotes.each(function(i, e) {
|
||||
var $aside = $(e);
|
||||
const $aside = $(e);
|
||||
if ($aside.data('post')) {
|
||||
self._updateQuoteElements($aside, 'chevron-down');
|
||||
var $title = $('.title', $aside);
|
||||
const $title = $('.title', $aside);
|
||||
|
||||
// Unless it's a full quote, allow click to expand
|
||||
if (!($aside.data('full') || $title.data('has-quote-controls'))) {
|
||||
|
@ -280,8 +280,8 @@ var PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
|||
}.on('didInsertElement'),
|
||||
|
||||
_applySearchHighlight: function() {
|
||||
var highlight = this.get('controller.searchHighlight');
|
||||
var cooked = this.$('.cooked');
|
||||
const highlight = this.get('controller.searchHighlight');
|
||||
const cooked = this.$('.cooked');
|
||||
|
||||
if(!cooked){ return; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user