diff --git a/.hound.yml b/.hound.yml new file mode 100644 index 000000000..762af91d4 --- /dev/null +++ b/.hound.yml @@ -0,0 +1,4 @@ +java_script: + enabled: true + config_file: config/.jshint.json + ignore_file: config/.jshint_ignore diff --git a/Gemfile b/Gemfile index 9cbeeb992..8697a61b1 100644 --- a/Gemfile +++ b/Gemfile @@ -217,6 +217,9 @@ group :development do gem 'rb-fsevent', '0.9.4', :require => false gem 'rb-inotify', '0.9.5', :require => false + # Linters + gem 'jshint', '1.3.1' + # Preloading environment gem 'spring', '1.2.0' @@ -261,5 +264,5 @@ group :development, :test do # Jasmine (client side application tests (JS)) gem 'jasmine', '2.1.0' gem 'jasmine-jquery-rails', '2.0.3' - gem 'sinon-rails', '1.10.3' + gem 'sinon-rails', '1.10.3' end diff --git a/Gemfile.lock b/Gemfile.lock index b1da44a53..71b14c7ff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -308,12 +308,17 @@ GEM sprockets-rails js_image_paths (0.0.1) rails (~> 4.0) + jshint (1.3.1) + execjs (>= 1.4.0) + multi_json (~> 1.0) + therubyracer (~> 0.12.1) json (1.8.1) jwt (1.0.0) kaminari (0.16.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) kgio (2.9.2) + libv8 (3.16.14.7) listen (2.8.3) celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) @@ -488,6 +493,7 @@ GEM redis (3.1.0) redis-namespace (1.5.1) redis (~> 3.0, >= 3.0.4) + ref (1.0.5) remotipart (1.2.1) request_store (1.1.0) responders (1.1.2) @@ -569,6 +575,9 @@ GEM systemu (2.6.4) test_after_commit (0.4.0) activerecord (>= 3.2) + therubyracer (0.12.1) + libv8 (~> 3.16.14.0) + ref thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) @@ -658,6 +667,7 @@ DEPENDENCIES jquery-rails (= 3.1.2) js-routes (= 0.9.9) js_image_paths (= 0.0.1) + jshint (= 1.3.1) json (= 1.8.1) markerb (= 1.0.2) messagebus_ruby_api (= 1.0.3) diff --git a/app/assets/javascripts/app/app.js b/app/assets/javascripts/app/app.js index 89a79031b..a3aa65c5e 100644 --- a/app/assets/javascripts/app/app.js +++ b/app/assets/javascripts/app/app.js @@ -35,8 +35,11 @@ var app = { events: _.extend({}, Backbone.Events), user: function(userAttrs) { - if(userAttrs) { return this._user = new app.models.User(userAttrs) } - return this._user || false + if(userAttrs) { + this._user = new app.models.User(userAttrs); + return this._user; + } + return this._user || false; }, initialize: function() { @@ -52,25 +55,25 @@ var app = { }, hasPreload : function(prop) { - return !!(window.gon.preloads && window.gon.preloads[prop]) //returning boolean variable so that parsePreloads, which cleans up properly is used instead + return !!(window.gon.preloads && window.gon.preloads[prop]); //returning boolean variable so that parsePreloads, which cleans up properly is used instead }, setPreload : function(prop, val) { - window.gon.preloads = window.gon.preloads || {} - window.gon.preloads[prop] = val + window.gon.preloads = window.gon.preloads || {}; + window.gon.preloads[prop] = val; }, parsePreload : function(prop) { if(!app.hasPreload(prop)) { return } - var preload = window.gon.preloads[prop] - delete window.gon.preloads[prop] //prevent dirty state across navigates + var preload = window.gon.preloads[prop]; + delete window.gon.preloads[prop]; //prevent dirty state across navigates - return(preload) + return(preload); }, setupDummyPreloads: function() { - if (window.gon == undefined) { + if (window.gon === undefined) { window.gon = {preloads:{}}; } }, @@ -101,8 +104,8 @@ var app = { evt.preventDefault(); var link = $(this); - $(".stream_title").text(link.text()) - app.router.navigate(link.attr("href").substring(1) ,true) + $(".stream_title").text(link.text()); + app.router.navigate(link.attr("href").substring(1) ,true); }); }, @@ -118,7 +121,7 @@ var app = { /* mixpanel wrapper function */ instrument : function(type, name, object, callback) { if(!window.mixpanel) { return } - window.mixpanel[type](name, object, callback) + window.mixpanel[type](name, object, callback); }, setupDisabledLinks: function() { @@ -132,4 +135,3 @@ $(function() { app.initialize(); }); // @license-end - diff --git a/app/assets/javascripts/app/collections/aspect_memberships.js b/app/assets/javascripts/app/collections/aspect_memberships.js index dd8ee1b5d..dc3c0410b 100644 --- a/app/assets/javascripts/app/collections/aspect_memberships.js +++ b/app/assets/javascripts/app/collections/aspect_memberships.js @@ -2,5 +2,5 @@ app.collections.AspectMemberships = Backbone.Collection.extend({ model: app.models.AspectMembership -}) +}); // @license-end diff --git a/app/assets/javascripts/app/collections/aspects.js b/app/assets/javascripts/app/collections/aspects.js index ce9fca6f5..1e284274b 100644 --- a/app/assets/javascripts/app/collections/aspects.js +++ b/app/assets/javascripts/app/collections/aspects.js @@ -25,6 +25,5 @@ app.collections.Aspects = Backbone.Collection.extend({ var separator = Diaspora.I18n.t("comma") + ' '; return this.selectedAspects('name').join(separator).replace(/,\s([^,]+)$/, ' ' + Diaspora.I18n.t("and") + ' $1') || Diaspora.I18n.t("my_aspects"); } -}) +}); // @license-end - diff --git a/app/assets/javascripts/app/collections/comments.js b/app/assets/javascripts/app/collections/comments.js index 34f4e8251..f096363e0 100644 --- a/app/assets/javascripts/app/collections/comments.js +++ b/app/assets/javascripts/app/collections/comments.js @@ -16,8 +16,8 @@ app.collections.Comments = Backbone.Collection.extend({ var deferred = comment.save({}, { url: '/posts/'+this.post.id+'/comments', success: function() { - comment.set({author: app.currentUser.toJSON(), parent: self.post }) - self.add(comment) + comment.set({author: app.currentUser.toJSON(), parent: self.post }); + self.add(comment); } }); @@ -25,4 +25,3 @@ app.collections.Comments = Backbone.Collection.extend({ } }); // @license-end - diff --git a/app/assets/javascripts/app/collections/likes.js b/app/assets/javascripts/app/collections/likes.js index d34a92270..76168237b 100644 --- a/app/assets/javascripts/app/collections/likes.js +++ b/app/assets/javascripts/app/collections/likes.js @@ -4,8 +4,7 @@ app.collections.Likes = Backbone.Collection.extend({ model: app.models.Like, initialize : function(models, options) { - this.url = "/posts/" + options.post.id + "/likes" //not delegating to post.url() because when it is in a stream collection it delegates to that url + this.url = "/posts/" + options.post.id + "/likes"; //not delegating to post.url() because when it is in a stream collection it delegates to that url } }); // @license-end - diff --git a/app/assets/javascripts/app/collections/photos.js b/app/assets/javascripts/app/collections/photos.js index da8c636a9..978858304 100644 --- a/app/assets/javascripts/app/collections/photos.js +++ b/app/assets/javascripts/app/collections/photos.js @@ -4,7 +4,7 @@ app.collections.Photos = Backbone.Collection.extend({ url : "/photos", model: function(attrs, options) { - var modelClass = app.models.Photo + var modelClass = app.models.Photo; return new modelClass(attrs, options); }, @@ -13,4 +13,3 @@ app.collections.Photos = Backbone.Collection.extend({ } }); // @license-end - diff --git a/app/assets/javascripts/app/helpers/date_formatter.js b/app/assets/javascripts/app/helpers/date_formatter.js index 1226d94c7..395e55f65 100644 --- a/app/assets/javascripts/app/helpers/date_formatter.js +++ b/app/assets/javascripts/app/helpers/date_formatter.js @@ -14,7 +14,6 @@ return timestamp || 0; } - } + }; })(); // @license-end - diff --git a/app/assets/javascripts/app/helpers/handlebars-helpers.js b/app/assets/javascripts/app/helpers/handlebars-helpers.js index 0b59ba93b..c428bfdd7 100644 --- a/app/assets/javascripts/app/helpers/handlebars-helpers.js +++ b/app/assets/javascripts/app/helpers/handlebars-helpers.js @@ -1,7 +1,7 @@ // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later Handlebars.registerHelper('t', function(scope, values) { - return Diaspora.I18n.t(scope, values.hash) + return Diaspora.I18n.t(scope, values.hash); }); Handlebars.registerHelper('txtDirClass', function(str) { @@ -29,7 +29,7 @@ Handlebars.registerHelper('linkToAuthor', function(context, block) { html += block.fn(context); html += ""; - return html + return html; }); Handlebars.registerHelper('linkToPerson', function(context, block) { @@ -38,7 +38,7 @@ Handlebars.registerHelper('linkToPerson', function(context, block) { html += block.fn(context); html += ""; - return html + return html; }); // relationship indicator for profile page @@ -61,7 +61,7 @@ Handlebars.registerHelper('sharingMessage', function(person) { // allow hovercards for users that are not the current user. // returns the html class name used to trigger hovercards. Handlebars.registerHelper('hovercardable', function(person) { - if( app.currentUser.get('guid') != person.guid ) { + if( app.currentUser.get('guid') !== person.guid ) { return 'hovercardable'; } return ''; @@ -104,7 +104,7 @@ Handlebars.registerHelper('fmtText', function(text) { Handlebars.registerHelper('isCurrentPage', function(path_helper, id, options){ var currentPage = "/"+Backbone.history.fragment; - if (currentPage == Handlebars.helpers.urlTo(path_helper, id, options.data)) { + if (currentPage === Handlebars.helpers.urlTo(path_helper, id, options.data)) { return options.fn(this); } else { return options.inverse(this); @@ -121,7 +121,7 @@ Handlebars.registerHelper('aspectMembershipIndicator', function(contact,in_aspec if(!app.aspect || !app.aspect.get('id')) return '
'; var html = '' + if (data.type === "photo") { + return '
');
},
- getLocation: function(e){
- element = this.el;
+ getLocation: function(){
+ var element = this.el;
- locator = new OSM.Locator();
+ var locator = new OSM.Locator();
locator.getAddress(function(address, latlng){
$(element).html('');
$('#location_coords').val(latlng.latitude + "," + latlng.longitude);
diff --git a/app/assets/javascripts/app/views/notifications_view.js b/app/assets/javascripts/app/views/notifications_view.js
index 0914440bf..bffd22c09 100644
--- a/app/assets/javascripts/app/views/notifications_view.js
+++ b/app/assets/javascripts/app/views/notifications_view.js
@@ -12,8 +12,8 @@ app.views.Notifications = Backbone.View.extend({
},
toggleUnread: function(evt) {
- note = $(evt.target).closest(".stream_element");
- unread = note.hasClass("unread");
+ var note = $(evt.target).closest(".stream_element");
+ var unread = note.hasClass("unread");
if (unread) {
this.setRead(note.data("guid"));
@@ -44,17 +44,17 @@ app.views.Notifications = Backbone.View.extend({
},
clickSuccess: function(data) {
- type = $('.stream_element[data-guid=' + data["guid"] + ']').data('type');
+ var type = $('.stream_element[data-guid=' + data["guid"] + ']').data('type');
this.updateView(data["guid"], type, data["unread"]);
},
updateView: function(guid, type, unread) {
- change = unread ? 1 : -1;
- all_notes = $('ul.nav > li:eq(0) .badge');
- type_notes = $('ul.nav > li[data-type=' + type + '] .badge');
- header_badge = $('#notification_badge .badge_count');
+ var change = unread ? 1 : -1,
+ all_notes = $('ul.nav > li:eq(0) .badge'),
+ type_notes = $('ul.nav > li[data-type=' + type + '] .badge'),
+ header_badge = $('#notification_badge .badge_count'),
+ note = $('.stream_element[data-guid=' + guid + ']');
- note = $('.stream_element[data-guid=' + guid + ']');
if(unread) {
note.removeClass("read").addClass("unread");
$(".unread-toggle .entypo", note)
@@ -93,4 +93,3 @@ app.views.Notifications = Backbone.View.extend({
}
});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/photo_viewer.js b/app/assets/javascripts/app/views/photo_viewer.js
index e2b8e939f..d9a587400 100644
--- a/app/assets/javascripts/app/views/photo_viewer.js
+++ b/app/assets/javascripts/app/views/photo_viewer.js
@@ -4,8 +4,7 @@ app.views.PhotoViewer = app.views.Base.extend({
templateName : "photo-viewer",
presenter : function(){
- return { photos : this.model.get("photos") } //json array of attributes, not backbone models, yet.
+ return { photos : this.model.get("photos") }; //json array of attributes, not backbone models, yet.
}
});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/photos_view.js b/app/assets/javascripts/app/views/photos_view.js
index bbba5766e..5d5969ef1 100644
--- a/app/assets/javascripts/app/views/photos_view.js
+++ b/app/assets/javascripts/app/views/photos_view.js
@@ -1,15 +1,15 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
app.views.Photos = app.views.InfScroll.extend({
- initialize : function(options) {
+ initialize : function() {
this.stream = this.model;
this.collection = this.stream.items;
// viable for extraction
this.stream.fetch();
- this.setupLightbox()
- this.setupInfiniteScroll()
+ this.setupLightbox();
+ this.setupInfiniteScroll();
},
postClass : app.views.Photo,
@@ -24,4 +24,3 @@ app.views.Photos = app.views.InfScroll.extend({
}
});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/poll_view.js b/app/assets/javascripts/app/views/poll_view.js
index ae6406bef..1ec3d1869 100644
--- a/app/assets/javascripts/app/views/poll_view.js
+++ b/app/assets/javascripts/app/views/poll_view.js
@@ -8,7 +8,7 @@ app.views.Poll = app.views.Base.extend({
"click .toggle_result" : "toggleResult"
},
- initialize: function(options) {
+ initialize: function() {
this.model.bind('change', this.render, this);
},
diff --git a/app/assets/javascripts/app/views/post_view.js b/app/assets/javascripts/app/views/post_view.js
index 195b468e1..726055bb7 100644
--- a/app/assets/javascripts/app/views/post_view.js
+++ b/app/assets/javascripts/app/views/post_view.js
@@ -6,12 +6,11 @@ app.views.Post = app.views.Base.extend({
authorIsCurrentUser : app.currentUser.isAuthorOf(this.model),
showPost : this.showPost(),
text : app.helpers.textFormatter(this.model.get("text"), this.model.get("mentioned_people"))
- })
+ });
},
showPost : function() {
- return (app.currentUser.get("showNsfw")) || !this.model.get("nsfw")
+ return (app.currentUser.get("showNsfw")) || !this.model.get("nsfw");
}
});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/profile_header_view.js b/app/assets/javascripts/app/views/profile_header_view.js
index 35bcded56..e44300b29 100644
--- a/app/assets/javascripts/app/views/profile_header_view.js
+++ b/app/assets/javascripts/app/views/profile_header_view.js
@@ -43,7 +43,7 @@ app.views.ProfileHeader = app.views.Base.extend({
postRenderTemplate: function() {
var self = this;
var dropdownEl = this.$('.aspect_membership_dropdown.placeholder');
- if( dropdownEl.length == 0 ) {
+ if( dropdownEl.length === 0 ) {
return;
}
diff --git a/app/assets/javascripts/app/views/publisher/aspect_selector_blueprint_view.js b/app/assets/javascripts/app/views/publisher/aspect_selector_blueprint_view.js
index 9ae3a9785..03f15f93d 100644
--- a/app/assets/javascripts/app/views/publisher/aspect_selector_blueprint_view.js
+++ b/app/assets/javascripts/app/views/publisher/aspect_selector_blueprint_view.js
@@ -9,6 +9,7 @@
// Provides the ability to specify the visibility of posted content as public
// or limited to selected aspects
app.views.PublisherAspectSelectorBlueprint = Backbone.View.extend({
+ /* global AspectsDropdown */
events: {
"click .dropdown_list > li": "toggleAspect"
@@ -21,7 +22,6 @@ app.views.PublisherAspectSelectorBlueprint = Backbone.View.extend({
// event handler for aspect selection
toggleAspect: function(evt) {
var el = $(evt.target);
- var btn = el.parent('.dropdown').find('.button');
// visually toggle the aspect selection
if( el.is('.radio') ) {
diff --git a/app/assets/javascripts/app/views/publisher/aspect_selector_view.js b/app/assets/javascripts/app/views/publisher/aspect_selector_view.js
index 1926f5b73..7145de4ad 100644
--- a/app/assets/javascripts/app/views/publisher/aspect_selector_view.js
+++ b/app/assets/javascripts/app/views/publisher/aspect_selector_view.js
@@ -35,7 +35,7 @@ app.views.PublisherAspectSelector = app.views.AspectsDropdown.extend({
// update the globe or lock icon
var icon = this.$('#visibility-icon');
- if (target.find('.text').text().trim() == Diaspora.I18n.t('stream.public')) {
+ if (target.find('.text').text().trim() === Diaspora.I18n.t('stream.public')) {
icon.removeClass('lock');
icon.addClass('globe');
} else {
diff --git a/app/assets/javascripts/app/views/publisher/getting_started_view.js b/app/assets/javascripts/app/views/publisher/getting_started_view.js
index a5896b8ad..6d36a83a7 100644
--- a/app/assets/javascripts/app/views/publisher/getting_started_view.js
+++ b/app/assets/javascripts/app/views/publisher/getting_started_view.js
@@ -65,7 +65,7 @@ app.views.PublisherGettingStarted = Backbone.View.extend({
var close = $(popup).find('.close');
close.click(function() {
- if( $('.popover').length==1 ) {
+ if( $('.popover').length === 1 ) {
$.get('/getting_started_completed', {success: function() {
$("#welcome-to-diaspora, #welcome-to-diaspora~br").remove();
}});
diff --git a/app/assets/javascripts/app/views/publisher/poll_creator_view.js b/app/assets/javascripts/app/views/publisher/poll_creator_view.js
index 3f49cbc17..e1c31fb2b 100644
--- a/app/assets/javascripts/app/views/publisher/poll_creator_view.js
+++ b/app/assets/javascripts/app/views/publisher/poll_creator_view.js
@@ -66,8 +66,7 @@ app.views.PublisherPollCreator = app.views.Base.extend({
this.$('input').val('');
},
- validate: function(evt){
- var input = $(evt.target);
+ validate: function(){
this.validatePoll();
this.trigger('change');
},
@@ -98,7 +97,7 @@ app.views.PublisherPollCreator = app.views.Base.extend({
// Validate the input unless it is the last one, or there are only the
// question field and two options
if( i !== inputs.length - 1 || inputs.length <= 3) {
- if(_this.validateInput($(input)) == false) pollValid = false;
+ if(_this.validateInput($(input)) === false) pollValid = false;
}
});
diff --git a/app/assets/javascripts/app/views/publisher/uploader_view.js b/app/assets/javascripts/app/views/publisher/uploader_view.js
index 39ef27433..00580f57a 100644
--- a/app/assets/javascripts/app/views/publisher/uploader_view.js
+++ b/app/assets/javascripts/app/views/publisher/uploader_view.js
@@ -47,7 +47,7 @@ app.views.PublisherUploader = Backbone.View.extend({
.width(progress + '%');
},
- submitHandler: function(id, fileName) {
+ submitHandler: function() {
this.$el.addClass('loading');
this._addPhotoPlaceholder();
},
@@ -66,7 +66,7 @@ app.views.PublisherUploader = Backbone.View.extend({
);
},
- uploadCompleteHandler: function(id, fileName, response) {
+ uploadCompleteHandler: function(_id, fileName, response) {
if (response.success){
this.el_info.text(Diaspora.I18n.t('photo_uploader.completed', {file: fileName})).fadeTo(2000, 0);
@@ -110,7 +110,7 @@ app.views.PublisherUploader = Backbone.View.extend({
.find('div.progress').remove();
// no more placeholders? enable buttons
- if( publisher.el_photozone.find('li.loading').length == 0 ) {
+ if( publisher.el_photozone.find('li.loading').length === 0 ) {
this.$el.removeClass('loading');
publisher.setButtonsEnabled(true);
}
@@ -127,7 +127,7 @@ app.views.PublisherUploader = Backbone.View.extend({
// remove an already uploaded photo
_removePhoto: function(evt) {
var self = this;
- var photo = $(evt.target).parents('.publisher_photo')
+ var photo = $(evt.target).parents('.publisher_photo');
var img = photo.find('img');
photo.addClass('dim');
@@ -139,7 +139,7 @@ app.views.PublisherUploader = Backbone.View.extend({
$.when(photo.fadeOut(400)).then(function(){
photo.remove();
- if( self.publisher.$('.publisher_photo').length == 0 ) {
+ if( self.publisher.$('.publisher_photo').length === 0 ) {
// no more photos left...
self.publisher.el_wrapper.removeClass('with_attachments');
}
@@ -154,4 +154,3 @@ app.views.PublisherUploader = Backbone.View.extend({
});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js
index 99f9e926e..48574bfe4 100644
--- a/app/assets/javascripts/app/views/publisher_view.js
+++ b/app/assets/javascripts/app/views/publisher_view.js
@@ -53,10 +53,10 @@ app.views.Publisher = Backbone.View.extend({
$(window).on('beforeunload', _.bind(this._beforeUnload, this));
// sync textarea content
- if( this.el_hiddenInput.val() == "" ) {
+ if( this.el_hiddenInput.val() === "" ) {
this.el_hiddenInput.val( this.el_input.val() );
}
- if( this.el_input.val() == "" ) {
+ if( this.el_input.val() === "" ) {
this.el_input.val( this.el_hiddenInput.val() );
}
@@ -71,11 +71,11 @@ app.views.Publisher = Backbone.View.extend({
// textchange event won't be called in Backbone...
this.el_input.bind('textchange', $.noop);
- var _this = this
+ var _this = this;
$('body').on('click', function(event){
// if the click event is happened outside the publisher view, then try to close the box
- if( _this.el && $(event.target).closest('#publisher').attr('id') != _this.el.id){
- _this.tryClose()
+ if( _this.el && $(event.target).closest('#publisher').attr('id') !== _this.el.id){
+ _this.tryClose();
}
});
@@ -210,7 +210,7 @@ app.views.Publisher = Backbone.View.extend({
// standalone means single-shot posting (until further notice)
if( self.standalone ) self.setEnabled(false);
},
- error: function(model, resp, options) {
+ error: function(model, resp) {
if( app.publisher ) app.publisher.trigger('publisher:error');
self.setInputEnabled(true);
Diaspora.page.flashMessages.render({ 'success':false, 'notice':resp.responseText });
@@ -222,7 +222,7 @@ app.views.Publisher = Backbone.View.extend({
// creates the location
showLocation: function(){
- if($('#location').length == 0){
+ if($('#location').length === 0){
$('#location_container').append('');
this.el_wrapper.addClass('with_location');
this.view_locator = new app.views.Location();
@@ -245,7 +245,7 @@ app.views.Publisher = Backbone.View.extend({
// avoid submitting form when pressing Enter key
avoidEnter: function(evt){
- if(evt.keyCode == 13)
+ if(evt.keyCode === 13)
return false;
},
@@ -257,7 +257,7 @@ app.views.Publisher = Backbone.View.extend({
var serializedForm = $(evt.target).closest("form").serializeObject();
- var photos = new Array();
+ var photos = [];
$('li.publisher_photo img').each(function(){
var file = $(this).attr('src').substring("/uploads/images/".length);
photos.push(
@@ -271,11 +271,19 @@ app.views.Publisher = Backbone.View.extend({
);
});
- var mentioned_people = new Array();
- var regexp = new RegExp("@{\(\[\^\;\]\+\); \(\[\^\}\]\+\)}", "g");
- while(user=regexp.exec(serializedForm["status_message[text]"])){
+ var mentioned_people = [],
+ regexp = new RegExp("@{\(\[\^\;\]\+\); \(\[\^\}\]\+\)}", "g"),
+ user;
+
+ var getMentionedUser = function(handle) {
+ return Mentions.contacts.filter(function(user) {
+ return user.handle === handle;
+ })[0];
+ };
+
+ while( (user = regexp.exec(serializedForm["status_message[text]"])) ){
// user[1]: name, user[2]: handle
- var mentioned_user = Mentions.contacts.filter(function(item) { return item.handle == user[2];})[0];
+ var mentioned_user = getMentionedUser(user[2]);
if(mentioned_user){
mentioned_people.push({
"id":mentioned_user["id"],
@@ -289,7 +297,7 @@ app.views.Publisher = Backbone.View.extend({
var date = (new Date()).toISOString();
- var poll = undefined;
+ var poll;
var poll_question = serializedForm["poll_question"];
var poll_answers_arry = _.flatten([serializedForm["poll_answers[]"]]);
var poll_answers = _.map(poll_answers_arry, function(answer){
@@ -308,7 +316,7 @@ app.views.Publisher = Backbone.View.extend({
var previewMessage = {
"id" : 0,
"text" : serializedForm["status_message[text]"],
- "public" : serializedForm["aspect_ids[]"]=="public",
+ "public" : serializedForm["aspect_ids[]"] === "public",
"created_at" : date,
"interacted_at" : date,
"post_type" : "StatusMessage",
@@ -349,7 +357,7 @@ app.views.Publisher = Backbone.View.extend({
},
keyDown : function(evt) {
- if( evt.keyCode == 13 && evt.ctrlKey ) {
+ if( evt.keyCode === 13 && evt.ctrlKey ) {
this.$("form").submit();
this.open();
return false;
@@ -406,7 +414,7 @@ app.views.Publisher = Backbone.View.extend({
tryClose : function(){
// if it is not submittable, close it.
if( !this._submittable() ){
- this.close()
+ this.close();
}
},
@@ -483,7 +491,7 @@ app.views.Publisher = Backbone.View.extend({
},
_beforeUnload: function(e) {
- if(this._submittable() && this.el_input.val() != this.prefillText){
+ if(this._submittable() && this.el_input.val() !== this.prefillText){
var confirmationMessage = Diaspora.I18n.t("confirm_unload");
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
return confirmationMessage; //Webkit, Safari, Chrome, etc.
@@ -509,4 +517,3 @@ $.fn.serializeObject = function()
return o;
};
// @license-end
-
diff --git a/app/assets/javascripts/app/views/single-post-viewer/single_post_actions.js b/app/assets/javascripts/app/views/single-post-viewer/single_post_actions.js
index eee0097ec..65ea3df45 100644
--- a/app/assets/javascripts/app/views/single-post-viewer/single_post_actions.js
+++ b/app/assets/javascripts/app/views/single-post-viewer/single_post_actions.js
@@ -10,14 +10,14 @@ app.views.SinglePostActions = app.views.Feedback.extend({
},
presenter: function() {
- var interactions = this.model.interactions
+ var interactions = this.model.interactions;
return _.extend(this.defaultPresenter(), {
authorIsNotCurrentUser : this.authorIsNotCurrentUser(),
userCanReshare : interactions.userCanReshare(),
userLike : interactions.userLike(),
userReshare : interactions.userReshare()
- })
+ });
},
renderPluginWidgets : function() {
@@ -32,9 +32,7 @@ app.views.SinglePostActions = app.views.Feedback.extend({
},
authorIsNotCurrentUser: function() {
- return app.currentUser.authenticated() && this.model.get("author").id != app.user().id
+ return app.currentUser.authenticated() && this.model.get("author").id !== app.user().id;
}
-
});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/single-post-viewer/single_post_comment_stream.js b/app/assets/javascripts/app/views/single-post-viewer/single_post_comment_stream.js
index 07f4d431d..e6c0d3857 100644
--- a/app/assets/javascripts/app/views/single-post-viewer/single_post_comment_stream.js
+++ b/app/assets/javascripts/app/views/single-post-viewer/single_post_comment_stream.js
@@ -9,25 +9,25 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({
highlightPermalinkComment: function() {
if(document.location.hash){
- element=$(document.location.hash);
- headerSize=50;
+ var element = $(document.location.hash);
+ var headerSize = 50;
$(".highlighted").removeClass("highlighted");
element.addClass("highlighted");
- pos=element.offset().top-headerSize;
+ var pos = element.offset().top - headerSize;
$("html").animate({scrollTop:pos});
}
},
postRenderTemplate: function() {
- app.views.CommentStream.prototype.postRenderTemplate.apply(this)
- this.$(".new_comment_form_wrapper").removeClass('hidden')
- _.defer(this.highlightPermalinkComment)
+ app.views.CommentStream.prototype.postRenderTemplate.apply(this);
+ this.$(".new_comment_form_wrapper").removeClass('hidden');
+ _.defer(this.highlightPermalinkComment);
},
appendComment: function(comment) {
// Set the post as the comment's parent, so we can check
// on post ownership in the Comment view.
- comment.set({parent : this.model.toJSON()})
+ comment.set({parent : this.model.toJSON()});
this.$(".comments").append(new app.views.ExpandedComment({
model: comment
@@ -39,8 +39,7 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({
moreCommentsCount : 0,
showExpandCommentsLink : false,
commentsCount : this.model.interactions.commentsCount()
- })
+ });
},
-})
+});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/single-post-viewer/single_post_content_view.js b/app/assets/javascripts/app/views/single-post-viewer/single_post_content_view.js
index 67f83f3b5..967b72f9f 100644
--- a/app/assets/javascripts/app/views/single-post-viewer/single_post_content_view.js
+++ b/app/assets/javascripts/app/views/single-post-viewer/single_post_content_view.js
@@ -32,12 +32,11 @@ app.views.SinglePostContent = app.views.Base.extend({
authorIsCurrentUser :app.currentUser.isAuthorOf(this.model),
showPost : this.showPost(),
text : app.helpers.textFormatter(this.model.get("text"), this.model.get("mentioned_people"))
- })
+ });
},
showPost : function() {
- return (app.currentUser.get("showNsfw")) || !this.model.get("nsfw")
+ return (app.currentUser.get("showNsfw")) || !this.model.get("nsfw");
}
});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/single-post-viewer/single_post_interactions.js b/app/assets/javascripts/app/views/single-post-viewer/single_post_interactions.js
index 19fa85435..b8c4a8661 100644
--- a/app/assets/javascripts/app/views/single-post-viewer/single_post_interactions.js
+++ b/app/assets/javascripts/app/views/single-post-viewer/single_post_interactions.js
@@ -10,11 +10,11 @@ app.views.SinglePostInteractions = app.views.Base.extend({
initialize : function() {
this.model.interactions.on('change', this.render, this);
- this.commentStreamView = new app.views.SinglePostCommentStream({model: this.model})
+ this.commentStreamView = new app.views.SinglePostCommentStream({model: this.model});
},
presenter : function(){
- var interactions = this.model.interactions
+ var interactions = this.model.interactions;
return {
likes : interactions.likes.toJSON(),
comments : interactions.comments.toJSON(),
@@ -22,8 +22,7 @@ app.views.SinglePostInteractions = app.views.Base.extend({
commentsCount : interactions.commentsCount(),
likesCount : interactions.likesCount(),
resharesCount : interactions.resharesCount(),
- }
+ };
},
});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/single-post-viewer/single_post_moderation.js b/app/assets/javascripts/app/views/single-post-viewer/single_post_moderation.js
index 4bece481a..a47f42d0a 100644
--- a/app/assets/javascripts/app/views/single-post-viewer/single_post_moderation.js
+++ b/app/assets/javascripts/app/views/single-post-viewer/single_post_moderation.js
@@ -8,8 +8,6 @@ app.views.SinglePostModeration = app.views.Feedback.extend({
},
presenter: function() {
- var interactions = this.model.interactions;
-
return _.extend(this.defaultPresenter(), {
authorIsCurrentUser : this.authorIsCurrentUser(),
});
@@ -21,7 +19,7 @@ app.views.SinglePostModeration = app.views.Feedback.extend({
},
authorIsCurrentUser: function() {
- return app.currentUser.authenticated() && this.model.get("author").id == app.user().id;
+ return app.currentUser.authenticated() && this.model.get("author").id === app.user().id;
},
destroyModel: function(evt) {
@@ -35,7 +33,7 @@ app.views.SinglePostModeration = app.views.Feedback.extend({
document.location.href = "/stream";
})
.fail(function() {
- var flash = new Diaspora.Widgets.FlashMessages;
+ var flash = new Diaspora.Widgets.FlashMessages();
flash.render({
success: false,
notice: Diaspora.I18n.t('failed_to_remove')
diff --git a/app/assets/javascripts/app/views/stream_faces_view.js b/app/assets/javascripts/app/views/stream_faces_view.js
index 9091c8bbe..0586f6df5 100644
--- a/app/assets/javascripts/app/views/stream_faces_view.js
+++ b/app/assets/javascripts/app/views/stream_faces_view.js
@@ -9,12 +9,12 @@ app.views.StreamFaces = app.views.Base.extend({
tooltipSelector : ".avatar",
initialize : function(){
- this.updatePeople()
- app.stream.items.bind("add", this.updatePeople, this)
+ this.updatePeople();
+ app.stream.items.bind("add", this.updatePeople, this);
},
presenter : function() {
- return {people : this.people}
+ return {people : this.people};
},
updatePeople : function(){
@@ -30,4 +30,3 @@ app.views.StreamFaces = app.views.Base.extend({
}
});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/stream_post_views.js b/app/assets/javascripts/app/views/stream_post_views.js
index 3fe47f3e8..da34f8bd8 100644
--- a/app/assets/javascripts/app/views/stream_post_views.js
+++ b/app/assets/javascripts/app/views/stream_post_views.js
@@ -54,7 +54,7 @@ app.views.StreamPost = app.views.Post.extend({
var normalizedClass = this.model.get("post_type").replace(/::/, "__")
, postClass = app.views[normalizedClass] || app.views.StatusMessage;
- return new postClass({ model : this.model })
+ return new postClass({ model : this.model });
},
postLocationStreamView : function(){
@@ -63,7 +63,7 @@ app.views.StreamPost = app.views.Post.extend({
removeNsfwShield: function(evt){
if(evt){ evt.preventDefault(); }
- this.model.set({nsfw : false})
+ this.model.set({nsfw : false});
this.render();
},
@@ -88,7 +88,7 @@ app.views.StreamPost = app.views.Post.extend({
remove : function() {
$(this.el).slideUp(400, _.bind(function(){this.$el.remove()}, this));
- return this
+ return this;
},
hidePost : function(evt) {
@@ -121,6 +121,5 @@ app.views.StreamPost = app.views.Post.extend({
return this;
}
-})
+});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/stream_view.js b/app/assets/javascripts/app/views/stream_view.js
index ca3058279..9d5d036ca 100644
--- a/app/assets/javascripts/app/views/stream_view.js
+++ b/app/assets/javascripts/app/views/stream_view.js
@@ -5,17 +5,17 @@
app.views.Stream = app.views.InfScroll.extend(_.extend(
app.views.StreamShortcuts, {
- initialize: function(options) {
- this.stream = this.model
- this.collection = this.stream.items
+ initialize: function() {
+ this.stream = this.model;
+ this.collection = this.stream.items;
- this.postViews = []
+ this.postViews = [];
- this.setupNSFW()
- this.setupLightbox()
- this.setupInfiniteScroll()
- this.setupShortcuts()
- this.markNavSelected()
+ this.setupNSFW();
+ this.setupLightbox();
+ this.setupInfiniteScroll();
+ this.setupShortcuts();
+ this.markNavSelected();
},
postClass : app.views.StreamPost,
@@ -26,11 +26,10 @@ app.views.Stream = app.views.InfScroll.extend(_.extend(
},
setupNSFW : function(){
- app.currentUser.bind("nsfwChanged", reRenderPostViews, this)
-
function reRenderPostViews() {
- _.map(this.postViews, function(view){ view.render() })
+ _.map(this.postViews, function(view){ view.render() });
}
+ app.currentUser.bind("nsfwChanged", reRenderPostViews, this);
},
markNavSelected : function() {
@@ -41,4 +40,3 @@ app.views.Stream = app.views.InfScroll.extend(_.extend(
}
}));
// @license-end
-
diff --git a/app/assets/javascripts/app/views/tag_following_action_view.js b/app/assets/javascripts/app/views/tag_following_action_view.js
index 2f770c1b9..37d95ff2a 100644
--- a/app/assets/javascripts/app/views/tag_following_action_view.js
+++ b/app/assets/javascripts/app/views/tag_following_action_view.js
@@ -20,7 +20,7 @@ app.views.TagFollowingAction = app.views.Base.extend({
return _.extend(this.defaultPresenter(), {
tag_is_followed : this.tag_is_followed(),
followString : this.followString()
- })
+ });
},
followString : function() {
@@ -35,7 +35,7 @@ app.views.TagFollowingAction = app.views.Base.extend({
return !this.model.isNew();
},
- getTagFollowing : function(tagFollowing) {
+ getTagFollowing : function() {
this.model = app.tagFollowings.where({"name":this.tagText})[0] ||
new app.models.TagFollowing({"name":this.tagText});
this.model.bind("change", this.render, this);
@@ -63,4 +63,3 @@ app.views.TagFollowingAction = app.views.Base.extend({
}
});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/tag_following_list_view.js b/app/assets/javascripts/app/views/tag_following_list_view.js
index d067b21df..dd05875e4 100644
--- a/app/assets/javascripts/app/views/tag_following_list_view.js
+++ b/app/assets/javascripts/app/views/tag_following_list_view.js
@@ -41,9 +41,9 @@ app.views.TagFollowingList = app.views.Base.extend({
});
this.$("input").bind('keydown', function(evt){
- if(evt.keyCode == 13 || evt.keyCode == 9 || evt.keyCode == 32){
+ if(evt.keyCode === 13 || evt.keyCode === 9 || evt.keyCode === 32){
evt.preventDefault();
- if( $('li.as-result-item.active').length == 0 ){
+ if( $('li.as-result-item.active').length === 0 ){
$('li.as-result-item').first().click();
}
}
@@ -62,7 +62,6 @@ app.views.TagFollowingList = app.views.Base.extend({
createTagFollowing: function(evt) {
if(evt){ evt.preventDefault(); }
- var name = this.$(".tag_input").val();
this.collection.create({"name":this.$(".tag_input").val()});
this.$(".tag_input").val("");
@@ -80,4 +79,3 @@ app.views.TagFollowingList = app.views.Base.extend({
},
});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/tag_following_view.js b/app/assets/javascripts/app/views/tag_following_view.js
index 611b74f14..838fd896d 100644
--- a/app/assets/javascripts/app/views/tag_following_view.js
+++ b/app/assets/javascripts/app/views/tag_following_view.js
@@ -29,9 +29,8 @@ app.views.TagFollowing = app.views.Base.extend({
presenter : function() {
return _.extend(this.defaultPresenter(), {
tag : this.model
- })
+ });
}
});
// @license-end
-
diff --git a/app/assets/javascripts/app/views/tags_view.js b/app/assets/javascripts/app/views/tags_view.js
index 2f736a206..cf13dbb49 100644
--- a/app/assets/javascripts/app/views/tags_view.js
+++ b/app/assets/javascripts/app/views/tags_view.js
@@ -2,9 +2,8 @@
app.views.Tags = Backbone.View.extend({
- initialize: function(opts) {
+ initialize: function() {
app.publisher.setText("#"+ this.tagName + " ");
}
});
// @license-end
-
diff --git a/app/assets/javascripts/aspects-dropdown.js b/app/assets/javascripts/aspects-dropdown.js
index 99ce1fac0..6c1ea03bc 100644
--- a/app/assets/javascripts/aspects-dropdown.js
+++ b/app/assets/javascripts/aspects-dropdown.js
@@ -10,36 +10,37 @@ var AspectsDropdown = {
selectedAspects = dropdown.children(".selected").length,
allAspects = dropdown.children().length,
replacement,
+ message,
isInPublisher = dropdown.closest('#publisher').length;
- if (number == 0) {
+ if (number === 0) {
button.removeClass(inAspectClass);
if (isInPublisher) {
replacement = Diaspora.I18n.t("aspect_dropdown.select_aspects");
} else {
replacement = Diaspora.I18n.t("aspect_dropdown.add_to_aspect");
/* flash message prompt */
- var message = Diaspora.I18n.t("aspect_dropdown.stopped_sharing_with", {name: dropdown.data('person-short-name')});
+ message = Diaspora.I18n.t("aspect_dropdown.stopped_sharing_with", {name: dropdown.data('person-short-name')});
Diaspora.page.flashMessages.render({success: true, notice: message});
}
- } else if (selectedAspects == allAspects) {
+ } else if (selectedAspects === allAspects) {
replacement = Diaspora.I18n.t('aspect_dropdown.all_aspects');
- } else if (number == 1) {
+ } else if (number === 1) {
button.addClass(inAspectClass);
replacement = dropdown.find(".selected").first().text();
/* flash message prompt */
if (!isInPublisher) {
- var message = Diaspora.I18n.t("aspect_dropdown.started_sharing_with", {name: dropdown.data('person-short-name')});
+ message = Diaspora.I18n.t("aspect_dropdown.started_sharing_with", {name: dropdown.data('person-short-name')});
Diaspora.page.flashMessages.render({success: true, notice: message});
}
} else {
- replacement = Diaspora.I18n.t('aspect_dropdown.toggle', { count: number.toString()})
+ replacement = Diaspora.I18n.t('aspect_dropdown.toggle', { count: number.toString()});
}
// if we are in the publisher, we add the visibility icon
if (isInPublisher) {
var icon = $('#visibility-icon');
- if (replacement.trim() == Diaspora.I18n.t('stream.public')) {
+ if (replacement.trim() === Diaspora.I18n.t('stream.public')) {
icon.removeClass('lock');
icon.addClass('globe');
} else {
@@ -74,6 +75,4 @@ var AspectsDropdown = {
});
}
};
-
// @license-end
-
diff --git a/app/assets/javascripts/clear-form.js b/app/assets/javascripts/clear-form.js
index db97fee95..0d361f3ac 100644
--- a/app/assets/javascripts/clear-form.js
+++ b/app/assets/javascripts/clear-form.js
@@ -10,7 +10,7 @@ $.fn.clearForm = function() {
$(this).attr('checked', false);
} else if ($(this).is('select')) {
this.selectedIndex = -1;
- } else if ($(this).attr('name') == 'photos[]') {
+ } else if ($(this).attr('name') === 'photos[]') {
$(this).val('');
}
$(this).blur();
diff --git a/app/assets/javascripts/diaspora.js b/app/assets/javascripts/diaspora.js
index df60703f3..054905786 100644
--- a/app/assets/javascripts/diaspora.js
+++ b/app/assets/javascripts/diaspora.js
@@ -21,14 +21,18 @@
var eventNames = eventName.split(" ");
for(eventName in eventNames) {
- this.eventsContainer.trigger(eventNames[eventName], args);
+ if(eventNames.hasOwnProperty(eventName)) {
+ this.eventsContainer.trigger(eventNames[eventName], args);
+ }
}
},
subscribe: function(eventName, callback, context) {
var eventNames = eventName.split(" ");
for(eventName in eventNames) {
- this.eventsContainer.bind(eventNames[eventName], $.proxy(callback, context));
+ if(eventNames.hasOwnProperty(eventName)) {
+ this.eventsContainer.bind(eventNames[eventName], $.proxy(callback, context));
+ }
}
}
});
@@ -38,7 +42,7 @@
};
Diaspora.BaseWidget = {
- instantiate: function(Widget, element) {
+ instantiate: function(Widget) {
// Mobile version loads only some widgets
if (typeof Diaspora.Widgets[Widget] === 'undefined') return;
@@ -85,18 +89,16 @@
if(!$.mobile)//why does this need this?
$.extend(Diaspora.page, new Diaspora.BasePage($(document.body)));
- Diaspora.page.publish("page/ready", [$(document.body)])
+ Diaspora.page.publish("page/ready", [$(document.body)]);
};
// temp hack to check if backbone is enabled for the page
Diaspora.backboneEnabled = function(){
return window.app && window.app.stream !== undefined;
- }
+ };
window.Diaspora = Diaspora;
})();
-
$(Diaspora.instantiatePage);
// @license-end
-
diff --git a/app/assets/javascripts/helpers/i18n.js b/app/assets/javascripts/helpers/i18n.js
index 3e4a01fe0..9be574c45 100644
--- a/app/assets/javascripts/helpers/i18n.js
+++ b/app/assets/javascripts/helpers/i18n.js
@@ -6,7 +6,7 @@ Diaspora.I18n = {
pluralizationKey: function(n) { return this.fallback.pluralizationKey(n); },
data: {},
fallback: {
- pluralizationKey: function(n) { return n == 1 ? "one" : "other"; },
+ pluralizationKey: function(n) { return n === 1 ? "one" : "other"; },
data: {}
}
},
@@ -20,9 +20,12 @@ Diaspora.I18n = {
updateLocale: function(locale, data) {
locale.data = $.extend(locale.data, data);
- rule = this._resolve(locale, ['pluralization_rule']);
+ var rule = this._resolve(locale, ['pluralization_rule']);
if (rule !== "") {
+ /* jshint evil:true */
+ // TODO change this to `locale.pluralizationKey = rule`?
eval("locale.pluralizationKey = "+rule);
+ /* jshint evil:false */
}
},
@@ -37,7 +40,7 @@ Diaspora.I18n = {
_resolve: function(locale, items) {
var translatedMessage, nextNamespace, originalItems = items.slice();
- while(nextNamespace = items.shift()) {
+ while( (nextNamespace = items.shift()) ) {
translatedMessage = (translatedMessage)
? translatedMessage[nextNamespace]
: locale.data[nextNamespace];
diff --git a/app/assets/javascripts/inbox.js b/app/assets/javascripts/inbox.js
index 758ff5e68..6ec1d03dc 100644
--- a/app/assets/javascripts/inbox.js
+++ b/app/assets/javascripts/inbox.js
@@ -24,7 +24,7 @@ $(document).ready(function(){
cBadge.html().replace(/\d+/, function(num){
num = parseInt(num);
cBadge.html(parseInt(num)-1);
- if(num == 1) {
+ if(num === 1) {
cBadge.addClass("hidden");
}
});
diff --git a/app/assets/javascripts/jsxc.js b/app/assets/javascripts/jsxc.js
index 456813851..e297ae0f6 100644
--- a/app/assets/javascripts/jsxc.js
+++ b/app/assets/javascripts/jsxc.js
@@ -39,7 +39,7 @@ $(document).ready(function() {
overwrite: true,
onlogin: true
}
- }
+ };
}
});
} else {
diff --git a/app/assets/javascripts/mobile/mobile.js b/app/assets/javascripts/mobile/mobile.js
index af1a3c336..a687c47c5 100644
--- a/app/assets/javascripts/mobile/mobile.js
+++ b/app/assets/javascripts/mobile/mobile.js
@@ -81,7 +81,7 @@ $(document).ready(function(){
dataType: 'json',
type: 'DELETE',
beforeSend: showLoader(link),
- complete: function(data){
+ complete: function(){
removeLoader(link);
link.attr("href", href.replace(/\/\d+$/, ''));
@@ -110,10 +110,10 @@ $(document).ready(function(){
dataType: 'json',
type: 'POST',
beforeSend: showLoader(link),
- success: function(data){
+ success: function(){
removeLoader(link);
},
- error: function(data){
+ error: function(){
removeLoader(link);
alert("Failed to reshare!");
}
@@ -128,7 +128,7 @@ $(document).ready(function(){
evt.preventDefault();
var link = $(this),
parent = link.closest(".bottom_bar").first(),
- commentsContainer = function(){ return parent.find(".comment_container").first(); }
+ commentsContainer = function(){ return parent.find(".comment_container").first(); },
existingCommentsContainer = commentsContainer();
if( link.hasClass('active') ) {
@@ -200,7 +200,7 @@ $(document).ready(function(){
context: link,
success: function(data){
var textarea = function(target) { return target.closest(".stream_element").find('textarea.comment_box').first()[0] };
- link.removeClass('loading')
+ link.removeClass('loading');
if(!link.hasClass("add_comment_bottom_link")){
link.removeClass('inactive');
@@ -217,9 +217,9 @@ $(document).ready(function(){
$(".stream").delegate("a.cancel_new_comment", "tap click", function(evt){
evt.preventDefault();
- var link = $(this);
+ var link = $(this),
form = link.closest("form"),
- commentActionLink = link.closest(".bottom_bar").find("a.comment_action").first();
+ commentActionLink = link.closest(".bottom_bar").find("a.comment_action").first(),
container = link.closest('.bottom_bar').find('.add_comment_bottom_link_container');
if(container.length > 0 ){
@@ -237,7 +237,7 @@ $(document).ready(function(){
$.post(form.attr('action')+"?format=mobile", form.serialize(), function(data){
var bottomBar = form.closest('.bottom_bar').first(),
container = bottomBar.find('.add_comment_bottom_link_container'),
- commentActionLink = bottomBar.find("a.comment_action").first();
+ commentActionLink = bottomBar.find("a.comment_action").first(),
reactionLink = bottomBar.find(".show_comments").first(),
commentCount = bottomBar.find(".comment_count");
@@ -247,13 +247,13 @@ $(document).ready(function(){
container.show();
} else {
- var container = $(""),
- comments = $("