Enable JSHINT's unused option. It caught a bunch of suspicious stuff which is fixed in this commit.

This commit is contained in:
Robin Ward 2013-12-30 13:29:52 -05:00
parent 8685e4079f
commit a502266c42
59 changed files with 69 additions and 102 deletions

View file

@ -50,7 +50,7 @@ Discourse.ScreenedIpAddressFormComponent = Ember.Component.extend({
} }
}, },
didInsertElement: function(e) { didInsertElement: function() {
var self = this; var self = this;
this._super(); this._super();
Em.run.schedule('afterRender', function() { Em.run.schedule('afterRender', function() {

View file

@ -13,9 +13,8 @@ Discourse.AdminApiController = Ember.ArrayController.extend({
Generates a master api key Generates a master api key
@method generateMasterKey @method generateMasterKey
@param {Discourse.ApiKey} the key to regenerate
**/ **/
generateMasterKey: function(key) { generateMasterKey: function() {
var self = this; var self = this;
Discourse.ApiKey.generateMasterKey().then(function (key) { Discourse.ApiKey.generateMasterKey().then(function (key) {
self.get('model').pushObject(key); self.get('model').pushObject(key);

View file

@ -7,7 +7,7 @@
Handlebars.registerHelper('valueAtTrustLevel', function(property, trustLevel) { Handlebars.registerHelper('valueAtTrustLevel', function(property, trustLevel) {
var data = Ember.Handlebars.get(this, property); var data = Ember.Handlebars.get(this, property);
if( data ) { if( data ) {
var item = data.find( function(d, i, arr) { return parseInt(d.x,10) === parseInt(trustLevel,10); } ); var item = data.find( function(d) { return parseInt(d.x,10) === parseInt(trustLevel,10); } );
if( item ) { if( item ) {
return item.y; return item.y;
} else { } else {

View file

@ -31,7 +31,7 @@ Discourse.AdminUser = Discourse.User.extend({
**/ **/
revokeApiKey: function() { revokeApiKey: function() {
var self = this; var self = this;
return Discourse.ajax("/admin/users/" + this.get('id') + "/revoke_api_key", {type: 'DELETE'}).then(function (result) { return Discourse.ajax("/admin/users/" + this.get('id') + "/revoke_api_key", {type: 'DELETE'}).then(function () {
self.set('api_key', null); self.set('api_key', null);
}); });
}, },
@ -51,7 +51,7 @@ Discourse.AdminUser = Discourse.User.extend({
"label": '<i class="fa fa-exclamation-triangle"></i> ' + I18n.t("admin.user.delete_all_posts"), "label": '<i class="fa fa-exclamation-triangle"></i> ' + I18n.t("admin.user.delete_all_posts"),
"class": "btn btn-danger", "class": "btn btn-danger",
"callback": function() { "callback": function() {
Discourse.ajax("/admin/users/" + (user.get('id')) + "/delete_all_posts", {type: 'PUT'}).then(function(result){ Discourse.ajax("/admin/users/" + (user.get('id')) + "/delete_all_posts", {type: 'PUT'}).then(function(){
user.set('post_count', 0); user.set('post_count', 0);
}); });
} }
@ -274,7 +274,7 @@ Discourse.AdminUser = Discourse.User.extend({
user.mergeAttributes(data.user); user.mergeAttributes(data.user);
} }
} }
}, function(jqXHR, status, error) { }, function() {
Discourse.AdminUser.find( user.get('username') ).then(function(u){ user.mergeAttributes(u); }); Discourse.AdminUser.find( user.get('username') ).then(function(u){ user.mergeAttributes(u); });
bootbox.alert(I18n.t("admin.user.delete_failed")); bootbox.alert(I18n.t("admin.user.delete_failed"));
}); });
@ -325,7 +325,7 @@ Discourse.AdminUser = Discourse.User.extend({
} else { } else {
bootbox.alert(I18n.t("admin.user.delete_failed")); bootbox.alert(I18n.t("admin.user.delete_failed"));
} }
}, function(jqXHR, status, error) { }, function() {
bootbox.alert(I18n.t("admin.user.delete_failed")); bootbox.alert(I18n.t("admin.user.delete_failed"));
}); });
} }

View file

@ -29,7 +29,6 @@ Discourse.ApiKey = Discourse.Model.extend({
@returns {Promise} a promise that resolves when the key has been revoked @returns {Promise} a promise that resolves when the key has been revoked
**/ **/
revoke: function() { revoke: function() {
var self = this;
return Discourse.ajax('/admin/api/key', {type: 'DELETE', data: {id: this.get('id')}}); return Discourse.ajax('/admin/api/key', {type: 'DELETE', data: {id: this.get('id')}});
} }

View file

@ -44,7 +44,7 @@ Discourse.Group = Discourse.Model.extend({
return Discourse.ajax("/admin/groups/" + group.get('id'), {type: "DELETE"}) return Discourse.ajax("/admin/groups/" + group.get('id'), {type: "DELETE"})
.then(function(){ .then(function(){
return true; return true;
}, function(error) { }, function() {
group.set('disableSave', false); group.set('disableSave', false);
bootbox.alert(I18n.t("admin.groups.delete_failed")); bootbox.alert(I18n.t("admin.groups.delete_failed"));
return false; return false;
@ -108,15 +108,5 @@ Discourse.Group.reopenClass({
}); });
return list; return list;
},
find: function(id) {
var promise = new Em.Deferred();
setTimeout(function(){
promise.resolve(Discourse.Group.create({id: 1, name: "all mods", members: ["A","b","c"]}));
}, 1000);
return promise;
} }
}); });

View file

@ -6,7 +6,7 @@ Discourse.Report = Discourse.Model.extend({
valueAt: function(numDaysAgo) { valueAt: function(numDaysAgo) {
if (this.data) { if (this.data) {
var wantedDate = moment().subtract('days', numDaysAgo).format('YYYY-MM-DD'); var wantedDate = moment().subtract('days', numDaysAgo).format('YYYY-MM-DD');
var item = this.data.find( function(d, i, arr) { return d.x === wantedDate; } ); var item = this.data.find( function(d) { return d.x === wantedDate; } );
if (item) { if (item) {
return item.y; return item.y;
} }

View file

@ -14,7 +14,7 @@ Discourse.ScreenedEmail = Discourse.Model.extend({
}); });
Discourse.ScreenedEmail.reopenClass({ Discourse.ScreenedEmail.reopenClass({
findAll: function(filter) { findAll: function() {
return Discourse.ajax("/admin/logs/screened_emails.json").then(function(screened_emails) { return Discourse.ajax("/admin/logs/screened_emails.json").then(function(screened_emails) {
return screened_emails.map(function(b) { return screened_emails.map(function(b) {
return Discourse.ScreenedEmail.create(b); return Discourse.ScreenedEmail.create(b);

View file

@ -45,7 +45,7 @@ Discourse.ScreenedIpAddress = Discourse.Model.extend({
}); });
Discourse.ScreenedIpAddress.reopenClass({ Discourse.ScreenedIpAddress.reopenClass({
findAll: function(filter) { findAll: function() {
return Discourse.ajax("/admin/logs/screened_ip_addresses.json").then(function(screened_ips) { return Discourse.ajax("/admin/logs/screened_ip_addresses.json").then(function(screened_ips) {
return screened_ips.map(function(b) { return screened_ips.map(function(b) {
return Discourse.ScreenedIpAddress.create(b); return Discourse.ScreenedIpAddress.create(b);

View file

@ -13,7 +13,7 @@ Discourse.ScreenedUrl = Discourse.Model.extend({
}); });
Discourse.ScreenedUrl.reopenClass({ Discourse.ScreenedUrl.reopenClass({
findAll: function(filter) { findAll: function() {
return Discourse.ajax("/admin/logs/screened_urls.json").then(function(screened_urls) { return Discourse.ajax("/admin/logs/screened_urls.json").then(function(screened_urls) {
return screened_urls.map(function(b) { return screened_urls.map(function(b) {
return Discourse.ScreenedUrl.create(b); return Discourse.ScreenedUrl.create(b);

View file

@ -12,7 +12,7 @@ Discourse.AdminSiteContentsRoute = Discourse.Route.extend({
return Discourse.SiteContentType.findAll(); return Discourse.SiteContentType.findAll();
}, },
renderTemplate: function(controller, model) { renderTemplate: function() {
this.render('admin/templates/site_contents', {into: 'admin/templates/admin'}); this.render('admin/templates/site_contents', {into: 'admin/templates/admin'});
this.render('admin/templates/site_contents_empty', {into: 'admin/templates/site_contents'}); this.render('admin/templates/site_contents_empty', {into: 'admin/templates/site_contents'});
}, },

View file

@ -42,7 +42,7 @@ Discourse.AceEditorView = Discourse.View.extend({
aceEditorView.editor.setTheme("ace/theme/chrome"); aceEditorView.editor.setTheme("ace/theme/chrome");
aceEditorView.editor.setShowPrintMargin(false); aceEditorView.editor.setShowPrintMargin(false);
aceEditorView.editor.getSession().setMode("ace/mode/" + (aceEditorView.get('mode'))); aceEditorView.editor.getSession().setMode("ace/mode/" + (aceEditorView.get('mode')));
aceEditorView.editor.on("change", function(e) { aceEditorView.editor.on("change", function() {
aceEditorView.skipContentChangeEvent = true; aceEditorView.skipContentChangeEvent = true;
aceEditorView.set('content', aceEditorView.editor.getSession().getValue()); aceEditorView.set('content', aceEditorView.editor.getSession().getValue());
aceEditorView.skipContentChangeEvent = false; aceEditorView.skipContentChangeEvent = false;

View file

@ -48,7 +48,7 @@ Discourse.EditTopicAutoCloseController = Discourse.ObjectController.extend(Disco
} else { } else {
bootbox.alert(I18n.t('composer.auto_close_error'), function() { self.send('showModal'); } ); bootbox.alert(I18n.t('composer.auto_close_error'), function() { self.send('showModal'); } );
} }
}, function (error) { }, function () {
bootbox.alert(I18n.t('composer.auto_close_error'), function() { self.send('showModal'); } ); bootbox.alert(I18n.t('composer.auto_close_error'), function() { self.send('showModal'); } );
}); });
} }

View file

@ -55,7 +55,7 @@ Discourse.ListTopicsController = Discourse.ObjectController.extend({
}, },
// Show newly inserted topics // Show newly inserted topics
showInserted: function(e) { showInserted: function() {
var tracker = Discourse.TopicTrackingState.current(); var tracker = Discourse.TopicTrackingState.current();
// Move inserted into topics // Move inserted into topics

View file

@ -61,7 +61,7 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona
$hidden_login_form.submit(); $hidden_login_form.submit();
} }
}, function(result) { }, function() {
// Failed to login // Failed to login
loginController.flash(I18n.t('login.error'), 'error'); loginController.flash(I18n.t('login.error'), 'error');
loginController.set('loggingIn', false); loginController.set('loggingIn', false);

View file

@ -183,7 +183,7 @@ Discourse.Dialect = {
@param {Function} emitter A function that emits the JsonML for the replacement. @param {Function} emitter A function that emits the JsonML for the replacement.
**/ **/
inlineReplace: function(token, emitter) { inlineReplace: function(token, emitter) {
this.registerInline(token, function(text, match, prev) { this.registerInline(token, function() {
return [token.length, emitter.call(this, token)]; return [token.length, emitter.call(this, token)];
}); });
}, },

View file

@ -5,8 +5,7 @@
@for Handlebars @for Handlebars
**/ **/
Handlebars.registerHelper('breakUp', function(property, hint, options) { Handlebars.registerHelper('breakUp', function(property, hint, options) {
var prop, result, tokens; var prop = Ember.Handlebars.get(this, property, options);
prop = Ember.Handlebars.get(this, property, options);
if (!prop) return ""; if (!prop) return "";
hint = Ember.Handlebars.get(this, hint, options); hint = Ember.Handlebars.get(this, hint, options);
@ -328,7 +327,7 @@ Handlebars.registerHelper('date', function(property, options) {
@method customHTML @method customHTML
@for Handlebars @for Handlebars
**/ **/
Handlebars.registerHelper('customHTML', function(property, options) { Handlebars.registerHelper('customHTML', function(property) {
var html = PreloadStore.get("customHTML"); var html = PreloadStore.get("customHTML");
if (html && html[property] && html[property].length) { if (html && html[property] && html[property].length) {

View file

@ -31,7 +31,7 @@ Discourse.addInitializer(function() {
// Observe file changes // Observe file changes
return Discourse.MessageBus.subscribe("/file-change", function(data) { return Discourse.MessageBus.subscribe("/file-change", function(data) {
Ember.TEMPLATES.empty = Handlebars.compile("<div></div>"); Ember.TEMPLATES.empty = Handlebars.compile("<div></div>");
_.each(data,function(me,idx) { _.each(data,function(me) {
if (me === "refresh") { if (me === "refresh") {
// Refresh if necessary // Refresh if necessary

View file

@ -141,7 +141,6 @@ $.fn.autocomplete = function(options) {
if (isInput) { if (isInput) {
var width = this.width(); var width = this.width();
var height = this.height();
wrap = this.wrap("<div class='ac-wrap clearfix" + (disabled ? " disabled": "") + "'/>").parent(); wrap = this.wrap("<div class='ac-wrap clearfix" + (disabled ? " disabled": "") + "'/>").parent();
wrap.width(width); wrap.width(width);
if(options.single) { if(options.single) {

View file

@ -32,7 +32,7 @@ $.fn.caretPosition = function(options) {
span = $("#pos span"); span = $("#pos span");
textarea = $(this); textarea = $(this);
getStyles = function(el, prop) { getStyles = function(el) {
if (el.currentStyle) { if (el.currentStyle) {
return el.currentStyle; return el.currentStyle;
} else { } else {

View file

@ -19,7 +19,6 @@ Discourse.Eyeline.prototype.update = function() {
var docViewTop = $(window).scrollTop(), var docViewTop = $(window).scrollTop(),
windowHeight = $(window).height(), windowHeight = $(window).height(),
docViewBottom = docViewTop + windowHeight, docViewBottom = docViewTop + windowHeight,
documentHeight = $(document).height(),
$elements = $(this.selector), $elements = $(this.selector),
atBottom = false, atBottom = false,
foundElement = false, foundElement = false,

View file

@ -151,7 +151,7 @@ Discourse.Formatter = (function(){
}; };
relativeAgeTiny = function(date, options){ relativeAgeTiny = function(date){
var format = "tiny"; var format = "tiny";
var distance = Math.round((new Date() - date) / 1000); var distance = Math.round((new Date() - date) / 1000);
var distanceInMinutes = Math.round(distance / 60.0); var distanceInMinutes = Math.round(distance / 60.0);
@ -226,7 +226,7 @@ Discourse.Formatter = (function(){
}; };
relativeAgeMedium = function(date, options){ relativeAgeMedium = function(date, options){
var displayDate, fiveDaysAgo, oneMinuteAgo, fullReadable, leaveAgo, val; var displayDate, fiveDaysAgo, oneMinuteAgo, fullReadable, leaveAgo;
var wrapInSpan = options.wrapInSpan === false ? false : true; var wrapInSpan = options.wrapInSpan === false ? false : true;
leaveAgo = options.leaveAgo; leaveAgo = options.leaveAgo;

View file

@ -9,7 +9,7 @@ Discourse.KeyValueStore = {
initialized: false, initialized: false,
context: "", context: "",
init: function(ctx, messageBus) { init: function(ctx) {
this.initialized = true; this.initialized = true;
this.context = ctx; this.context = ctx;
}, },

View file

@ -15,8 +15,7 @@ Discourse.Lightbox = {
callbacks: { callbacks: {
open: function() { open: function() {
var self = this, var wrap = this.wrap,
wrap = this.wrap,
img = this.currItem.img, img = this.currItem.img,
maxHeight = img.css("max-height"); maxHeight = img.css("max-height");

View file

@ -84,7 +84,7 @@ Discourse.ScreenTrack = Ember.Object.extend({
var newTimings = {}, var newTimings = {},
totalTimings = this.get('totalTimings'); totalTimings = this.get('totalTimings');
_.each(this.get('timings'), function(timing,key) { _.each(this.get('timings'), function(timing) {
if (!totalTimings[timing.postNumber]) if (!totalTimings[timing.postNumber])
totalTimings[timing.postNumber] = 0; totalTimings[timing.postNumber] = 0;

View file

@ -10,7 +10,7 @@
**/ **/
Discourse.LoadMore = Em.Mixin.create(Ember.ViewTargetActionSupport, Discourse.Scrolling, { Discourse.LoadMore = Em.Mixin.create(Ember.ViewTargetActionSupport, Discourse.Scrolling, {
scrolled: function(e) { scrolled: function() {
var eyeline = this.get('eyeline'); var eyeline = this.get('eyeline');
if (eyeline) { eyeline.update(); } if (eyeline) { eyeline.update(); }
}, },

View file

@ -20,7 +20,7 @@ Discourse.Scrolling = Em.Mixin.create({
opts = opts || {debounce: 100}; opts = opts || {debounce: 100};
var self = this, var self = this,
onScrollMethod = function(e) { onScrollMethod = function() {
return Em.run.scheduleOnce('afterRender', self, 'scrolled'); return Em.run.scheduleOnce('afterRender', self, 'scrolled');
}; };

View file

@ -51,7 +51,7 @@ Discourse.Category = Discourse.Model.extend({
return this.get('topic_count') > Discourse.SiteSettings.category_featured_topics; return this.get('topic_count') > Discourse.SiteSettings.category_featured_topics;
}.property('topic_count'), }.property('topic_count'),
save: function(args) { save: function() {
var url = "/categories"; var url = "/categories";
if (this.get('id')) { if (this.get('id')) {
url = "/categories/" + (this.get('id')); url = "/categories/" + (this.get('id'));
@ -81,7 +81,7 @@ Discourse.Category = Discourse.Model.extend({
return rval; return rval;
}.property("permissions"), }.property("permissions"),
destroy: function(callback) { destroy: function() {
return Discourse.ajax("/categories/" + (this.get('slug') || this.get('id')), { type: 'DELETE' }); return Discourse.ajax("/categories/" + (this.get('slug') || this.get('id')), { type: 'DELETE' });
}, },

View file

@ -420,7 +420,7 @@ Discourse.Composer = Discourse.Model.extend({
this.set('composeState', CLOSED); this.set('composeState', CLOSED);
return Ember.Deferred.promise(function(promise) { return Ember.Deferred.promise(function(promise) {
post.save(function(savedPost) { post.save(function() {
composer.clearState(); composer.clearState();
}, function(error) { }, function(error) {
var response = $.parseJSON(error.responseText); var response = $.parseJSON(error.responseText);
@ -486,8 +486,7 @@ Discourse.Composer = Discourse.Model.extend({
composer.set('composeState', SAVING); composer.set('composeState', SAVING);
createdPost.save(function(result) { createdPost.save(function(result) {
var addedPost = false, var saving = true;
saving = true;
createdPost.updateFromJson(result); createdPost.updateFromJson(result);

View file

@ -91,8 +91,7 @@ Discourse.Post = Discourse.Model.extend({
}.property('read', 'topic.last_read_post_number', 'bookmarked'), }.property('read', 'topic.last_read_post_number', 'bookmarked'),
bookmarkedChanged: function() { bookmarkedChanged: function() {
var post = this; Discourse.ajax("/posts/" + this.get('id') + "/bookmark", {
Discourse.ajax("/posts/" + (this.get('id')) + "/bookmark", {
type: 'PUT', type: 'PUT',
data: { data: {
bookmarked: this.get('bookmarked') ? true : false bookmarked: this.get('bookmarked') ? true : false

View file

@ -306,9 +306,7 @@ Discourse.PostStream = Em.Object.extend({
fillGapAfter: function(post, gap) { fillGapAfter: function(post, gap) {
var postId = post.get('id'), var postId = post.get('id'),
stream = this.get('stream'), stream = this.get('stream'),
idx = stream.indexOf(postId), idx = stream.indexOf(postId);
currentPosts = this.get('posts'),
self = this;
if (idx !== -1) { if (idx !== -1) {
stream.pushObjects(gap); stream.pushObjects(gap);
@ -674,8 +672,7 @@ Discourse.PostStream = Em.Object.extend({
var url = "/t/" + this.get('topic.id') + "/posts.json", var url = "/t/" + this.get('topic.id') + "/posts.json",
data = { post_ids: postIds }, data = { post_ids: postIds },
postStream = this, postStream = this;
result = Em.A();
return Discourse.ajax(url, {data: data}).then(function(result) { return Discourse.ajax(url, {data: data}).then(function(result) {
var posts = Em.get(result, "post_stream.posts"); var posts = Em.get(result, "post_stream.posts");

View file

@ -24,7 +24,7 @@ Discourse.Topic = Discourse.Model.extend({
return a !== 'regular' && a !== 'private_message'; return a !== 'regular' && a !== 'private_message';
}.property('archetype'), }.property('archetype'),
convertArchetype: function(archetype) { convertArchetype: function() {
var a = this.get('archetype'); var a = this.get('archetype');
if (a !== 'regular' && a !== 'private_message') { if (a !== 'regular' && a !== 'private_message') {
this.set('archetype', 'regular'); this.set('archetype', 'regular');
@ -233,7 +233,7 @@ Discourse.Topic = Discourse.Model.extend({
}, },
// Recover this topic if deleted // Recover this topic if deleted
recover: function(deleted_by) { recover: function() {
this.setProperties({ this.setProperties({
deleted_at: null, deleted_at: null,
deleted_by: null, deleted_by: null,
@ -326,14 +326,13 @@ Discourse.Topic.reopenClass({
// Load a topic, but accepts a set of filters // Load a topic, but accepts a set of filters
find: function(topicId, opts) { find: function(topicId, opts) {
var data, promise, url; var url = Discourse.getURL("/t/") + topicId;
url = Discourse.getURL("/t/") + topicId;
if (opts.nearPost) { if (opts.nearPost) {
url += "/" + opts.nearPost; url += "/" + opts.nearPost;
} }
data = {}; var data = {};
if (opts.postsAfter) { if (opts.postsAfter) {
data.posts_after = opts.postsAfter; data.posts_after = opts.postsAfter;
} }

View file

@ -66,7 +66,7 @@ Discourse.TopicDetails = Discourse.Model.extend({
Discourse.ajax("/t/" + this.get('topic.id') + "/remove-allowed-user", { Discourse.ajax("/t/" + this.get('topic.id') + "/remove-allowed-user", {
type: 'PUT', type: 'PUT',
data: { username: username } data: { username: username }
}).then(function(res) { }).then(function() {
users.removeObject(users.findProperty('username', username)); users.removeObject(users.findProperty('username', username));
}); });
} }

View file

@ -169,8 +169,7 @@ Discourse.TopicList.reopenClass({
topicsFrom: function(result) { topicsFrom: function(result) {
// Stitch together our side loaded data // Stitch together our side loaded data
var categories = Discourse.Category.list(), var categories = Discourse.Category.list(),
users = this.extractByKey(result.users, Discourse.User), users = this.extractByKey(result.users, Discourse.User);
topics = Em.A();
return result.topic_list.topics.map(function (t) { return result.topic_list.topics.map(function (t) {
t.category = categories.findBy('id', t.category_id); t.category = categories.findBy('id', t.category_id);

View file

@ -216,7 +216,7 @@ Ember.DiscourseLocation = Ember.Object.extend({
var guid = Ember.guidFor(this), var guid = Ember.guidFor(this),
self = this; self = this;
Ember.$(window).on('popstate.ember-location-'+guid, function(e) { Ember.$(window).on('popstate.ember-location-'+guid, function() {
// Ignore initial page load popstate event in Chrome // Ignore initial page load popstate event in Chrome
if (!popstateFired) { if (!popstateFired) {
popstateFired = true; popstateFired = true;

View file

@ -16,7 +16,7 @@ Discourse.Route = Em.Route.extend({
@method activate @method activate
**/ **/
activate: function(router, context) { activate: function() {
this._super(); this._super();
// Close mini profiler // Close mini profiler

View file

@ -10,7 +10,7 @@ Discourse.UserTopicListRoute = Discourse.Route.extend({
} }
}); });
function createPMRoute(viewName, path, type) { function createPMRoute(viewName, path) {
return Discourse.UserTopicListRoute.extend({ return Discourse.UserTopicListRoute.extend({
userActionType: Discourse.UserAction.TYPES.messages_received, userActionType: Discourse.UserAction.TYPES.messages_received,
@ -18,7 +18,7 @@ function createPMRoute(viewName, path, type) {
return Discourse.TopicList.find('topics/' + path + '/' + this.modelFor('user').get('username_lower')); return Discourse.TopicList.find('topics/' + path + '/' + this.modelFor('user').get('username_lower'));
}, },
setupController: function(controller, model) { setupController: function() {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.controllerFor('user').setProperties({ this.controllerFor('user').setProperties({
pmView: viewName, pmView: viewName,

View file

@ -18,7 +18,7 @@ Discourse.ClearPinButton = Discourse.ButtonView.extend({
return this.get('controller.pinned') ? null : 'hidden'; return this.get('controller.pinned') ? null : 'hidden';
}.property('controller.pinned'), }.property('controller.pinned'),
click: function(buffer) { click: function() {
this.get('controller').send('clearPin'); this.get('controller').send('clearPin');
}, },

View file

@ -10,7 +10,7 @@ Discourse.DropdownButtonView = Discourse.View.extend({
classNameBindings: [':btn-group', 'hidden'], classNameBindings: [':btn-group', 'hidden'],
shouldRerender: Discourse.View.renderIfChanged('text', 'longDescription'), shouldRerender: Discourse.View.renderIfChanged('text', 'longDescription'),
didInsertElement: function(e) { didInsertElement: function() {
// If there's a click handler, call it // If there's a click handler, call it
if (this.clicked) { if (this.clicked) {
var dropDownButtonView = this; var dropDownButtonView = this;
@ -22,7 +22,7 @@ Discourse.DropdownButtonView = Discourse.View.extend({
} }
}, },
willDestroyElement: function(e) { willDestroyElement: function() {
this.$('ul li').off('click.dropdown-button'); this.$('ul li').off('click.dropdown-button');
}, },

View file

@ -88,7 +88,7 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, {
}); });
}.observes('model.composeState'), }.observes('model.composeState'),
keyUp: function(e) { keyUp: function() {
var controller = this.get('controller'); var controller = this.get('controller');
controller.checkReplyLength(); controller.checkReplyLength();
@ -337,7 +337,7 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, {
return result; return result;
}, },
childDidInsertElement: function(e) { childDidInsertElement: function() {
return this.initEditor(); return this.initEditor();
}, },

View file

@ -55,7 +55,7 @@ Discourse.ListTopicsView = Discourse.View.extend(Discourse.LoadMore, {
}, },
// When the topic list is scrolled // When the topic list is scrolled
scrolled: function(e) { scrolled: function() {
this._super(); this._super();
this.saveScrollPosition(); this.saveScrollPosition();
} }

View file

@ -39,7 +39,7 @@ Discourse.AvatarSelectorView = Discourse.ModalBodyView.extend({
}); });
// when a file has been selected // when a file has been selected
$upload.on("fileuploadadd", function (e, data) { $upload.on("fileuploadadd", function () {
self.setProperties({ self.setProperties({
uploading: true, uploading: true,
imageIsNotASquare: false imageIsNotASquare: false
@ -81,7 +81,7 @@ Discourse.AvatarSelectorView = Discourse.ModalBodyView.extend({
}); });
// when the upload is done // when the upload is done
$upload.on("fileuploadalways", function (e, data) { $upload.on("fileuploadalways", function () {
self.setProperties({ uploading: false, uploadProgress: 0 }); self.setProperties({ uploading: false, uploadProgress: 0 });
}); });
}, },

View file

@ -11,7 +11,7 @@ Discourse.CreateAccountView = Discourse.ModalBodyView.extend({
title: I18n.t('create_account.title'), title: I18n.t('create_account.title'),
classNames: ['create-account'], classNames: ['create-account'],
didInsertElement: function(e) { didInsertElement: function() {
this._super(); this._super();

View file

@ -9,7 +9,7 @@
Discourse.HideModalView = Discourse.ModalBodyView.extend({ Discourse.HideModalView = Discourse.ModalBodyView.extend({
// No rendering! // No rendering!
render: function(buffer) { }, render: function() { },
didInsertElement: function() { didInsertElement: function() {
$('#discourse-modal').modal('hide'); $('#discourse-modal').modal('hide');

View file

@ -41,7 +41,7 @@ Discourse.LoginView = Discourse.ModalBodyView.extend({
}); });
}, },
didInsertElement: function(e) { didInsertElement: function() {
this._super(); this._super();

View file

@ -17,7 +17,7 @@ Discourse.PopupInputTipView = Discourse.View.extend({
bouncePixels: 6, bouncePixels: 6,
bounceDelay: 100, bounceDelay: 100,
click: function(e) { click: function() {
this.set('shownAt', false); this.set('shownAt', false);
}, },

View file

@ -56,10 +56,10 @@ Discourse.QuoteButtonView = Discourse.View.extend({
view.selectText(e.target, controller); view.selectText(e.target, controller);
view.set('isMouseDown', false); view.set('isMouseDown', false);
}) })
.on('touchstart.quote-button', function(e){ .on('touchstart.quote-button', function(){
view.set('isTouchInProgress', true); view.set('isTouchInProgress', true);
}) })
.on('touchend.quote-button', function(e){ .on('touchend.quote-button', function(){
view.set('isTouchInProgress', false); view.set('isTouchInProgress', false);
}) })
.on('selectionchange', function() { .on('selectionchange', function() {

View file

@ -71,7 +71,7 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
} }
}.observes('controller.enteredAt'), }.observes('controller.enteredAt'),
didInsertElement: function(e) { didInsertElement: function() {
this.bindScrolling({name: 'topic-view'}); this.bindScrolling({name: 'topic-view'});
var topicView = this; var topicView = this;

View file

@ -1,5 +1,3 @@
/*global Markdown:true*/
window.PagedownCustom = { window.PagedownCustom = {
insertButtons: [ insertButtons: [
{ {

View file

@ -34,6 +34,7 @@ regexp: false # true if . and [^...] should not be allowed in RegExp liter
safe: false # true if the safe subset rules are enforced (used by ADsafe) safe: false # true if the safe subset rules are enforced (used by ADsafe)
strict: false # true if the ES5 "use strict"; pragma is required strict: false # true if the ES5 "use strict"; pragma is required
undef: true # true if variables must be declared before used undef: true # true if variables must be declared before used
unused: true
white: false # true if strict whitespace rules apply (see also 'indent' option) white: false # true if strict whitespace rules apply (see also 'indent' option)
eqnull: false eqnull: false
onecase: true # allow for one case switches, can be more elegant sometimes onecase: true # allow for one case switches, can be more elegant sometimes

View file

@ -92,8 +92,7 @@ test("Select Replies when present", function() {
tc = testController(Discourse.TopicController, topic), tc = testController(Discourse.TopicController, topic),
p1 = Discourse.Post.create({id: 1, post_number: 1, reply_count: 1}), p1 = Discourse.Post.create({id: 1, post_number: 1, reply_count: 1}),
p2 = Discourse.Post.create({id: 2, post_number: 2}), p2 = Discourse.Post.create({id: 2, post_number: 2}),
p3 = Discourse.Post.create({id: 2, post_number: 3, reply_to_post_number: 1}), p3 = Discourse.Post.create({id: 2, post_number: 3, reply_to_post_number: 1});
postStream = tc.get('postStream');
ok(!tc.postSelected(p3), "replies are not selected by default"); ok(!tc.postSelected(p3), "replies are not selected by default");
tc.send('toggledSelectedPostReplies', p1); tc.send('toggledSelectedPostReplies', p1);

View file

@ -150,6 +150,7 @@ var jsHintOpts = {
"plusplus": false, "plusplus": false,
"regexp": false, "regexp": false,
"undef": true, "undef": true,
"unused": true,
"sub": true, "sub": true,
"strict": false, "strict": false,
"white": false, "white": false,

View file

@ -1,4 +1,3 @@
/*global md5:true */
module("Discourse.BBCode"); module("Discourse.BBCode");
var format = function(input, expected, text) { var format = function(input, expected, text) {

View file

@ -28,10 +28,6 @@ var formatDays = function(days) {
return formatHours(days * 24); return formatHours(days * 24);
}; };
var formatMonths = function(months) {
return formatDays(months * 30);
};
var shortDate = function(days){ var shortDate = function(days){
return moment().subtract('days', days).format('D MMM'); return moment().subtract('days', days).format('D MMM');
}; };

View file

@ -1,7 +1,5 @@
module("Discourse.HTML"); module("Discourse.HTML");
var html = Discourse.HTML;
test("categoryLink without a category", function() { test("categoryLink without a category", function() {
blank(Discourse.HTML.categoryLink(), "it returns no HTML"); blank(Discourse.HTML.categoryLink(), "it returns no HTML");
}); });

View file

@ -1,5 +1,3 @@
/*global sanitizeHtml:true */
module("Discourse.Markdown", { module("Discourse.Markdown", {
setup: function() { setup: function() {
Discourse.SiteSettings.traditional_markdown_linebreaks = false; Discourse.SiteSettings.traditional_markdown_linebreaks = false;
@ -173,7 +171,7 @@ test("Quotes", function() {
"handles quotes properly"); "handles quotes properly");
cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2", cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2",
{ topicId: 2, lookupAvatar: function(name) { } }, { topicId: 2, lookupAvatar: function() { } },
"<p>1</p>\n\n<p><aside class=\"quote\" data-post=\"1\"><div class=\"title\"><div class=\"quote-controls\"></div>bob said:" + "<p>1</p>\n\n<p><aside class=\"quote\" data-post=\"1\"><div class=\"title\"><div class=\"quote-controls\"></div>bob said:" +
"</div><blockquote><p>my quote</p></blockquote></aside></p>\n\n<p>2</p>", "</div><blockquote><p>my quote</p></blockquote></aside></p>\n\n<p>2</p>",
"includes no avatar if none is found"); "includes no avatar if none is found");

View file

@ -1,6 +1,6 @@
module("Discourse.SelectedPostsCount"); module("Discourse.SelectedPostsCount");
var buildTestObj = function(params, topicParams) { var buildTestObj = function(params) {
return Ember.Object.createWithMixins(Discourse.SelectedPostsCount, params || {}); return Ember.Object.createWithMixins(Discourse.SelectedPostsCount, params || {});
}; };

View file

@ -1,7 +1,7 @@
module("Discourse.Composer"); module("Discourse.Composer");
test('replyLength', function() { test('replyLength', function() {
var replyLength = function(val, expectedLength, text) { var replyLength = function(val, expectedLength) {
var composer = Discourse.Composer.create({ reply: val }); var composer = Discourse.Composer.create({ reply: val });
equal(composer.get('replyLength'), expectedLength); equal(composer.get('replyLength'), expectedLength);
}; };

View file

@ -227,7 +227,7 @@ test("storePost", function() {
test("identity map", function() { test("identity map", function() {
var postStream = buildStream(1234); var postStream = buildStream(1234);
var p1 = postStream.appendPost(Discourse.Post.create({id: 1, post_number: 1})); var p1 = postStream.appendPost(Discourse.Post.create({id: 1, post_number: 1}));
var p3 = postStream.appendPost(Discourse.Post.create({id: 3, post_number: 4})); postStream.appendPost(Discourse.Post.create({id: 3, post_number: 4}));
equal(postStream.findLoadedPost(1), p1, "it can return cached posts by id"); equal(postStream.findLoadedPost(1), p1, "it can return cached posts by id");
blank(postStream.findLoadedPost(4), "it can't find uncached posts"); blank(postStream.findLoadedPost(4), "it can't find uncached posts");
@ -403,7 +403,7 @@ test("comitting and triggerNewPostInStream race condition", function() {
var user = Discourse.User.create({username: 'eviltrout', name: 'eviltrout', id: 321}); var user = Discourse.User.create({username: 'eviltrout', name: 'eviltrout', id: 321});
var stagedPost = Discourse.Post.create({ raw: 'hello world this is my new post' }); var stagedPost = Discourse.Post.create({ raw: 'hello world this is my new post' });
var result = postStream.stagePost(stagedPost, user); postStream.stagePost(stagedPost, user);
equal(postStream.get('filteredPostsCount'), 0, "it has no filteredPostsCount yet"); equal(postStream.get('filteredPostsCount'), 0, "it has no filteredPostsCount yet");
stagedPost.set('id', 123); stagedPost.set('id', 123);