Simplify return statements

This commit is contained in:
riking 2014-03-18 18:23:15 -07:00
parent 3f35d1062e
commit 86774fa5c1
8 changed files with 13 additions and 22 deletions

View File

@ -44,8 +44,7 @@ Discourse.UserInvitedController = Ember.ArrayController.extend({
@property showSearch @property showSearch
**/ **/
showSearch: function() { showSearch: function() {
if (Em.isNone(this.get('searchTerm')) && this.get('model.length') === 0) { return false; } return !(Em.isNone(this.get('searchTerm')) && this.get('model.length') === 0);
return true;
}.property('searchTerm', 'model.length'), }.property('searchTerm', 'model.length'),
/** /**

View File

@ -120,10 +120,10 @@ function parseTree(tree, path, insideCounts) {
**/ **/
function invalidBoundary(args, prev) { function invalidBoundary(args, prev) {
if (!args.wordBoundary && !args.spaceBoundary) { return; } if (!args.wordBoundary && !args.spaceBoundary) { return false; }
var last = prev[prev.length - 1]; var last = prev[prev.length - 1];
if (typeof last !== "string") { return; } if (typeof last !== "string") { return false; }
if (args.wordBoundary && (last.match(/(\w|\/)$/))) { return true; } if (args.wordBoundary && (last.match(/(\w|\/)$/))) { return true; }
if (args.spaceBoundary && (!last.match(/\s$/))) { return true; } if (args.spaceBoundary && (!last.match(/\s$/))) { return true; }
@ -149,10 +149,9 @@ Discourse.Dialect = {
cook: function(text, opts) { cook: function(text, opts) {
if (!initialized) { initializeDialects(); } if (!initialized) { initializeDialects(); }
dialect.options = opts; dialect.options = opts;
var tree = parser.toHTMLTree(text, 'Discourse'), var tree = parser.toHTMLTree(text, 'Discourse');
html = parser.renderJsonML(parseTree(tree));
return html; return parser.renderJsonML(parseTree(tree));
}, },
/** /**

View File

@ -237,7 +237,7 @@ relativeAgeMediumSpan = function(distance, leaveAgo) {
relativeAgeMedium = function(date, options){ relativeAgeMedium = function(date, options){
var displayDate, fiveDaysAgo, oneMinuteAgo, fullReadable, leaveAgo; var displayDate, fiveDaysAgo, oneMinuteAgo, fullReadable, leaveAgo;
var wrapInSpan = options.wrapInSpan === false ? false : true; var wrapInSpan = options.wrapInSpan !== false;
leaveAgo = options.leaveAgo; leaveAgo = options.leaveAgo;
var distance = Math.round((new Date() - date) / 1000); var distance = Math.round((new Date() - date) / 1000);

View File

@ -14,7 +14,7 @@ Discourse.Mobile = {
this.mobileView = $html.hasClass('mobile-view'); this.mobileView = $html.hasClass('mobile-view');
if (localStorage && localStorage.mobileView) { if (localStorage && localStorage.mobileView) {
var savedValue = (localStorage.mobileView === 'true' ? true : false); var savedValue = (localStorage.mobileView === 'true');
if (savedValue !== this.mobileView) { if (savedValue !== this.mobileView) {
this.reloadPage(savedValue); this.reloadPage(savedValue);
} }

View File

@ -54,8 +54,7 @@ Discourse.UserSearch = {
users.push(u); users.push(u);
results.push(u); results.push(u);
} }
if (results.length > limit) return false; return results.length <= limit;
return true;
}); });
_.each(r.groups,function(g) { _.each(r.groups,function(g) {

View File

@ -126,14 +126,10 @@ Discourse.Composer = Discourse.Model.extend({
// reply is always required // reply is always required
if (this.get('missingReplyCharacters') > 0) return true; if (this.get('missingReplyCharacters') > 0) return true;
if (this.get('canCategorize') && return this.get('canCategorize') &&
!Discourse.SiteSettings.allow_uncategorized_topics && !Discourse.SiteSettings.allow_uncategorized_topics &&
!this.get('categoryId') && !this.get('categoryId') &&
!Discourse.User.currentProp('staff')) { !Discourse.User.currentProp('staff');
return true;
}
return false;
}.property('loading', 'canEditTitle', 'titleLength', 'targetUsernames', 'replyLength', 'categoryId', 'missingReplyCharacters'), }.property('loading', 'canEditTitle', 'titleLength', 'targetUsernames', 'replyLength', 'categoryId', 'missingReplyCharacters'),
/** /**

View File

@ -103,11 +103,10 @@ Discourse.Post = Discourse.Model.extend({
}.property('updated_at'), }.property('updated_at'),
flagsAvailable: function() { flagsAvailable: function() {
var post = this, var post = this;
flags = Discourse.Site.currentProp('flagTypes').filter(function(item) { return Discourse.Site.currentProp('flagTypes').filter(function(item) {
return post.get("actionByName." + (item.get('name_key')) + ".can_act"); return post.get("actionByName." + (item.get('name_key')) + ".can_act");
}); });
return flags;
}.property('actions_summary.@each.can_act'), }.property('actions_summary.@each.can_act'),
actionsHistory: function() { actionsHistory: function() {

View File

@ -168,8 +168,7 @@ Discourse.Topic = Discourse.Model.extend({
if (!wordCount) return; if (!wordCount) return;
// Avg for 500 words per minute when you account for skimming // Avg for 500 words per minute when you account for skimming
var minutes = Math.floor(wordCount / 500.0); return Math.floor(wordCount / 500.0);
return minutes;
}.property('word_count'), }.property('word_count'),
toggleStar: function() { toggleStar: function() {