Improve code formatting

This commit is contained in:
Robin Ward 2015-06-03 11:33:57 -04:00
parent 4029aa3dfc
commit 2a0084ff87

View File

@ -13,23 +13,23 @@ export default Discourse.View.extend(StringBuffer, {
'data-topic-id': Em.computed.alias('topic.id'), 'data-topic-id': Em.computed.alias('topic.id'),
actions: { actions: {
select: function(){ select() {
this.set('controller.selectedRow', this); this.set('controller.selectedRow', this);
}, },
toggleBookmark: function() { toggleBookmark() {
var self = this; const self = this;
this.get('topic').toggleBookmark().finally(function() { this.get('topic').toggleBookmark().finally(function() {
self.rerender(); self.rerender();
}); });
} }
}, },
selected: function(){ selected: function() {
return this.get('controller.selectedRow')===this; return this.get('controller.selectedRow')===this;
}.property('controller.selectedRow'), }.property('controller.selectedRow'),
unboundClassNames: function(){ unboundClassNames: function() {
let classes = []; let classes = [];
const topic = this.get('topic'); const topic = this.get('topic');
@ -37,12 +37,12 @@ export default Discourse.View.extend(StringBuffer, {
classes.push("category-" + topic.get('category.fullSlug')); classes.push("category-" + topic.get('category.fullSlug'));
} }
if(topic.get('hasExcerpt')){ if (topic.get('hasExcerpt')) {
classes.push('has-excerpt'); classes.push('has-excerpt');
} }
_.each(['liked', 'archived', 'bookmarked'],function(name){ _.each(['liked', 'archived', 'bookmarked'],function(name) {
if(topic.get(name)){ if (topic.get(name)) {
classes.push(name); classes.push(name);
} }
}); });
@ -50,72 +50,72 @@ export default Discourse.View.extend(StringBuffer, {
return classes.join(' '); return classes.join(' ');
}.property(), }.property(),
titleColSpan: function(){ titleColSpan: function() {
return (!this.get('controller.hideCategory') && return (!this.get('controller.hideCategory') &&
this.get('topic.isPinnedUncategorized') ? 2 : 1); this.get('topic.isPinnedUncategorized') ? 2 : 1);
}.property("topic.isPinnedUncategorized"), }.property("topic.isPinnedUncategorized"),
hasLikes: function(){ hasLikes: function() {
return this.get('topic.like_count') > 0; return this.get('topic.like_count') > 0;
}, },
hasOpLikes: function(){ hasOpLikes: function() {
return this.get('topic.op_like_count') > 0; return this.get('topic.op_like_count') > 0;
}, },
expandPinned: function(){ expandPinned: function() {
var pinned = this.get('topic.pinned'); const pinned = this.get('topic.pinned');
if(!pinned){ if (!pinned) {
return false; return false;
} }
if(this.get('controller.expandGloballyPinned') && this.get('topic.pinned_globally')){ if (this.get('controller.expandGloballyPinned') && this.get('topic.pinned_globally')) {
return true; return true;
} }
if(this.get('controller.expandAllPinned')){ if (this.get('controller.expandAllPinned')) {
return true; return true;
} }
return false; return false;
}.property(), }.property(),
click: function(e){ click(e) {
var target = $(e.target); let target = $(e.target);
if(target.hasClass('posts-map')){ if (target.hasClass('posts-map')) {
if(target.prop('tagName') !== 'A'){ if (target.prop('tagName') !== 'A') {
target = target.find('a'); target = target.find('a');
} }
this.container.lookup('controller:application').send("showTopicEntrance", {topic: this.get('topic'), position: target.offset()}); this.container.lookup('controller:application').send("showTopicEntrance", {topic: this.get('topic'), position: target.offset()});
return false; return false;
} }
if(target.hasClass('bulk-select')){ if (target.hasClass('bulk-select')) {
var selected = this.get('controller.selected'); const selected = this.get('controller.selected');
var topic = this.get('topic'); const topic = this.get('topic');
if(target.is(':checked')){ if (target.is(':checked')) {
selected.addObject(topic); selected.addObject(topic);
} else { } else {
selected.removeObject(topic); selected.removeObject(topic);
} }
} }
if(target.closest('a.topic-status').length === 1){ if (target.closest('a.topic-status').length === 1) {
this.get('topic').togglePinnedForUser(); this.get('topic').togglePinnedForUser();
return false; return false;
} }
}, },
highlight: function() { highlight() {
var $topic = this.$(); const $topic = this.$();
var originalCol = $topic.css('backgroundColor'); const originalCol = $topic.css('backgroundColor');
$topic $topic
.addClass('highlighted') .addClass('highlighted')
.stop() .stop()
.animate({ backgroundColor: originalCol }, 2500, 'swing', function(){ .animate({ backgroundColor: originalCol }, 2500, 'swing', function() {
$topic.removeClass('highlighted'); $topic.removeClass('highlighted');
}); });
}, },