From 6b0a5823e34d3904dd9ae25161eec4ed8da69df7 Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Sun, 8 Feb 2015 18:21:40 +0100 Subject: [PATCH 1/6] Add JSHint javascript linter --- Gemfile | 5 +- Gemfile.lock | 10 +++ app/assets/javascripts/app/app.js | 2 +- .../javascripts/app/helpers/truncate.js | 2 +- .../app/models/post/interactions.js | 4 +- app/assets/javascripts/app/models/stream.js | 2 +- app/assets/javascripts/app/views.js | 2 +- .../views/aspect_membership_blueprint_view.js | 6 +- .../app/views/aspect_membership_view.js | 4 +- .../javascripts/app/views/aspect_view.js | 2 +- .../app/views/aspects_dropdown_view.js | 2 +- .../app/views/aspects_list_view.js | 2 +- .../javascripts/app/views/contact_view.js | 2 +- .../javascripts/app/views/content_view.js | 6 +- .../javascripts/app/views/hovercard_view.js | 8 +- .../app/views/profile_header_view.js | 2 +- .../app/views/publisher/poll_creator_view.js | 2 +- .../app/views/publisher/uploader_view.js | 6 +- .../javascripts/app/views/publisher_view.js | 12 +-- .../single_post_moderation.js | 2 +- .../app/views/tag_following_list_view.js | 2 +- app/assets/javascripts/aspects-dropdown.js | 7 +- app/assets/javascripts/diaspora.js | 8 +- app/assets/javascripts/mobile/mobile.js | 4 +- .../mobile/mobile_file_uploader.js | 4 +- app/assets/javascripts/osmlocator.js | 2 +- .../pages/users-getting-started.js | 2 +- app/assets/javascripts/widgets/lightbox.js | 6 +- config/jshint.yml | 44 +++++++++++ .../app/helpers/text_formatter_spec.js | 4 +- spec/javascripts/app/models/photo_spec.js | 2 +- spec/javascripts/app/models/post_spec.js | 2 +- .../app/views/feedback_view_spec.js | 2 +- .../app/views/publisher_view_spec.js | 2 +- .../javascripts/app/views/stream_post_spec.js | 4 +- spec/javascripts/helpers/SpecHelper.js | 79 ++++++++++--------- spec/javascripts/helpers/factory.js | 12 --- spec/javascripts/helpers/mock-ajax.js | 6 +- 38 files changed, 166 insertions(+), 109 deletions(-) create mode 100644 config/jshint.yml 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..c353a3c99 100644 --- a/app/assets/javascripts/app/app.js +++ b/app/assets/javascripts/app/app.js @@ -70,7 +70,7 @@ var app = { }, setupDummyPreloads: function() { - if (window.gon == undefined) { + if (window.gon === undefined) { window.gon = {preloads:{}}; } }, diff --git a/app/assets/javascripts/app/helpers/truncate.js b/app/assets/javascripts/app/helpers/truncate.js index 122a259b7..7cfa6aa59 100644 --- a/app/assets/javascripts/app/helpers/truncate.js +++ b/app/assets/javascripts/app/helpers/truncate.js @@ -1,6 +1,6 @@ (function() { app.helpers.truncate = function(passedString, length) { - if (passedString == null || passedString == undefined) { + if (passedString === null || passedString === undefined) { return passedString; } diff --git a/app/assets/javascripts/app/models/post/interactions.js b/app/assets/javascripts/app/models/post/interactions.js index 5a157ef32..3c188188c 100644 --- a/app/assets/javascripts/app/models/post/interactions.js +++ b/app/assets/javascripts/app/models/post/interactions.js @@ -84,7 +84,7 @@ app.models.Post.Interactions = Backbone.Model.extend({ var self = this; this.comments.make(text).fail(function () { - flash = new Diaspora.Widgets.FlashMessages; + flash = new Diaspora.Widgets.FlashMessages(); flash.render({ success: false, notice: Diaspora.I18n.t("failed_to_post_message") @@ -101,7 +101,7 @@ app.models.Post.Interactions = Backbone.Model.extend({ reshare : function(){ var interactions = this , reshare = this.post.reshare() - , flash = new Diaspora.Widgets.FlashMessages; + , flash = new Diaspora.Widgets.FlashMessages(); reshare.save({}, { success : function(resp){ diff --git a/app/assets/javascripts/app/models/stream.js b/app/assets/javascripts/app/models/stream.js index 2e0c1e799..54a51a747 100644 --- a/app/assets/javascripts/app/models/stream.js +++ b/app/assets/javascripts/app/models/stream.js @@ -42,7 +42,7 @@ app.models.Stream = Backbone.Collection.extend({ this.trigger("fetched", this); // all loaded? var respItems = this.items.parse(resp); - if(respItems && (respItems.author || respItems.length == 0)) { + if(respItems && (respItems.author || respItems.length === 0)) { this.trigger("allItemsLoaded", this); } }, diff --git a/app/assets/javascripts/app/views.js b/app/assets/javascripts/app/views.js index 9605dd966..a677e54d4 100644 --- a/app/assets/javascripts/app/views.js +++ b/app/assets/javascripts/app/views.js @@ -132,7 +132,7 @@ app.views.Base = Backbone.View.extend({ }) .fail(function() { self.$el.removeClass('deleting'); - 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/aspect_membership_blueprint_view.js b/app/assets/javascripts/app/views/aspect_membership_blueprint_view.js index cf0f59e2c..622ba3d7c 100644 --- a/app/assets/javascripts/app/views/aspect_membership_blueprint_view.js +++ b/app/assets/javascripts/app/views/aspect_membership_blueprint_view.js @@ -75,7 +75,7 @@ app.views.AspectMembershipBlueprint = Backbone.View.extend({ // the user didn't have this person in any aspects before, congratulate them // on their newly found friendship ;) - if( this.dropdown.find('li.selected').length == 0 ) { + if( this.dropdown.find('li.selected').length === 0 ) { var msg = Diaspora.I18n.t('aspect_dropdown.started_sharing_with', { 'name': this._name() }); Diaspora.page.flashMessages.render({ 'success':true, 'notice':msg }); } @@ -121,7 +121,7 @@ app.views.AspectMembershipBlueprint = Backbone.View.extend({ // we just removed the last aspect, inform the user with a flash message // that he is no longer sharing with that person - if( this.dropdown.find('li.selected').length == 0 ) { + if( this.dropdown.find('li.selected').length === 0 ) { var msg = Diaspora.I18n.t('aspect_dropdown.stopped_sharing_with', { 'name': this._name() }); Diaspora.page.flashMessages.render({ 'success':true, 'notice':msg }); } @@ -143,7 +143,7 @@ app.views.AspectMembershipBlueprint = Backbone.View.extend({ var aspects_cnt = this.dropdown.find('li.selected').length; var txt; - if( aspects_cnt == 0 ) { + if( aspects_cnt === 0 ) { btn.removeClass('in_aspects'); txt = Diaspora.I18n.t('aspect_dropdown.toggle.zero'); } else { diff --git a/app/assets/javascripts/app/views/aspect_membership_view.js b/app/assets/javascripts/app/views/aspect_membership_view.js index 8348f26b6..d22452421 100644 --- a/app/assets/javascripts/app/views/aspect_membership_view.js +++ b/app/assets/javascripts/app/views/aspect_membership_view.js @@ -75,7 +75,7 @@ app.views.AspectMembership = app.views.AspectsDropdown.extend({ // the user didn't have this person in any aspects before, congratulate them // on their newly found friendship ;) - if( this.dropdown.find('li.selected').length == 0 ) { + if( this.dropdown.find('li.selected').length === 0 ) { var msg = Diaspora.I18n.t('aspect_dropdown.started_sharing_with', { 'name': this._name() }); Diaspora.page.flashMessages.render({ 'success':true, 'notice':msg }); } @@ -120,7 +120,7 @@ app.views.AspectMembership = app.views.AspectsDropdown.extend({ // we just removed the last aspect, inform the user with a flash message // that he is no longer sharing with that person - if( this.dropdown.find('li.selected').length == 0 ) { + if( this.dropdown.find('li.selected').length === 0 ) { var msg = Diaspora.I18n.t('aspect_dropdown.stopped_sharing_with', { 'name': this._name() }); Diaspora.page.flashMessages.render({ 'success':true, 'notice':msg }); } diff --git a/app/assets/javascripts/app/views/aspect_view.js b/app/assets/javascripts/app/views/aspect_view.js index 982301370..4d986ee9d 100644 --- a/app/assets/javascripts/app/views/aspect_view.js +++ b/app/assets/javascripts/app/views/aspect_view.js @@ -12,7 +12,7 @@ app.views.Aspect = app.views.Base.extend({ }, toggleAspect: function(evt) { - if (evt) { evt.preventDefault(); }; + if (evt) { evt.preventDefault(); } this.model.toggleSelected(); app.router.aspects_stream(); diff --git a/app/assets/javascripts/app/views/aspects_dropdown_view.js b/app/assets/javascripts/app/views/aspects_dropdown_view.js index 65c5c8e00..c87ed275b 100644 --- a/app/assets/javascripts/app/views/aspects_dropdown_view.js +++ b/app/assets/javascripts/app/views/aspects_dropdown_view.js @@ -32,7 +32,7 @@ app.views.AspectsDropdown = app.views.Base.extend({ selectedAspects = this.$(".dropdown-menu > li.selected").length, buttonText; - if (selectedAspects == 0) { + if (selectedAspects === 0) { button.removeClass(inAspectClass).addClass('btn-default'); buttonText = Diaspora.I18n.t("aspect_dropdown.select_aspects"); } else { diff --git a/app/assets/javascripts/app/views/aspects_list_view.js b/app/assets/javascripts/app/views/aspects_list_view.js index 60416567c..61f671645 100644 --- a/app/assets/javascripts/app/views/aspects_list_view.js +++ b/app/assets/javascripts/app/views/aspects_list_view.js @@ -29,7 +29,7 @@ app.views.AspectsList = app.views.Base.extend({ }, toggleAll: function(evt) { - if (evt) { evt.preventDefault(); }; + if (evt) { evt.preventDefault(); } if (this.collection.allSelected()) { this.collection.deselectAll(); diff --git a/app/assets/javascripts/app/views/contact_view.js b/app/assets/javascripts/app/views/contact_view.js index 4fd2d7efb..297bec059 100644 --- a/app/assets/javascripts/app/views/contact_view.js +++ b/app/assets/javascripts/app/views/contact_view.js @@ -21,7 +21,7 @@ app.views.Contact = 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/content_view.js b/app/assets/javascripts/app/views/content_view.js index f5e7061e5..71c641141 100644 --- a/app/assets/javascripts/app/views/content_view.js +++ b/app/assets/javascripts/app/views/content_view.js @@ -17,7 +17,7 @@ app.views.Content = app.views.Base.extend({ largePhoto : function() { var photos = this.model.get("photos") - if(!photos || photos.length == 0) { return } + if(!photos || photos.length === 0) { return } return photos[0] }, @@ -49,10 +49,10 @@ app.views.Content = app.views.Base.extend({ , oembed = elem.find(".oembed") , opengraph = elem.find(".opengraph") , addHeight = 0; - if($.trim(oembed.html()) != "") { + if($.trim(oembed.html()) !== "") { addHeight += oembed.height(); } - if($.trim(opengraph.html()) != "") { + if($.trim(opengraph.html()) !== "") { addHeight += opengraph.height(); } diff --git a/app/assets/javascripts/app/views/hovercard_view.js b/app/assets/javascripts/app/views/hovercard_view.js index 4cb5c6356..e4497b18a 100644 --- a/app/assets/javascripts/app/views/hovercard_view.js +++ b/app/assets/javascripts/app/views/hovercard_view.js @@ -41,7 +41,7 @@ app.views.Hovercard = app.views.Base.extend({ }, _mouseenterHandler: function(event) { - if( this.active == false || + if( this.active === false || $.contains(this.el, event.target) ) { return false; } var el = $(event.target); @@ -60,7 +60,7 @@ app.views.Hovercard = app.views.Base.extend({ }, _mouseleaveHandler: function(event) { - if( this.active == false || + if( this.active === false || $.contains(this.el, event.relatedTarget) ) { return false; } this.show_me = false; @@ -95,7 +95,7 @@ app.views.Hovercard = app.views.Base.extend({ var self = this; $.get(href, function(person){ - if( !person || person.length == 0 ) { + if( !person || person.length === 0 ) { throw new Error("received data is not a person object"); } @@ -123,7 +123,7 @@ app.views.Hovercard = app.views.Base.extend({ // TODO render me client side!!! var href = this.href(); href += "/aspect_membership_button"; - if(gon.bootstrap == true){ + if(gon.bootstrap === true){ href += "?bootstrap=true"; } $.get(href, function(response) { 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/poll_creator_view.js b/app/assets/javascripts/app/views/publisher/poll_creator_view.js index 3f49cbc17..45920b2c8 100644 --- a/app/assets/javascripts/app/views/publisher/poll_creator_view.js +++ b/app/assets/javascripts/app/views/publisher/poll_creator_view.js @@ -98,7 +98,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..302d6c335 100644 --- a/app/assets/javascripts/app/views/publisher/uploader_view.js +++ b/app/assets/javascripts/app/views/publisher/uploader_view.js @@ -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); } @@ -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'); } diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 99f9e926e..79443d1ec 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() ); } @@ -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(); @@ -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,7 +271,7 @@ app.views.Publisher = Backbone.View.extend({ ); }); - var mentioned_people = new Array(); + var mentioned_people = []; var regexp = new RegExp("@{\(\[\^\;\]\+\); \(\[\^\}\]\+\)}", "g"); while(user=regexp.exec(serializedForm["status_message[text]"])){ // user[1]: name, user[2]: handle @@ -289,7 +289,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){ 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..15062c651 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 @@ -35,7 +35,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/tag_following_list_view.js b/app/assets/javascripts/app/views/tag_following_list_view.js index d067b21df..a44f3e296 100644 --- a/app/assets/javascripts/app/views/tag_following_list_view.js +++ b/app/assets/javascripts/app/views/tag_following_list_view.js @@ -43,7 +43,7 @@ app.views.TagFollowingList = app.views.Base.extend({ this.$("input").bind('keydown', function(evt){ 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(); } } diff --git a/app/assets/javascripts/aspects-dropdown.js b/app/assets/javascripts/aspects-dropdown.js index 99ce1fac0..fceb73af8 100644 --- a/app/assets/javascripts/aspects-dropdown.js +++ b/app/assets/javascripts/aspects-dropdown.js @@ -10,16 +10,17 @@ 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) { @@ -29,7 +30,7 @@ var AspectsDropdown = { 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 { diff --git a/app/assets/javascripts/diaspora.js b/app/assets/javascripts/diaspora.js index df60703f3..ea469b90f 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)); + } } } }); diff --git a/app/assets/javascripts/mobile/mobile.js b/app/assets/javascripts/mobile/mobile.js index af1a3c336..6354b6bd2 100644 --- a/app/assets/javascripts/mobile/mobile.js +++ b/app/assets/javascripts/mobile/mobile.js @@ -247,8 +247,8 @@ $(document).ready(function(){ container.show(); } else { - var container = $("
"), - comments = $(""); + var comments = $(""); + container = $("
"); comments.html(data); container.append(comments); diff --git a/app/assets/javascripts/mobile/mobile_file_uploader.js b/app/assets/javascripts/mobile/mobile_file_uploader.js index ac17956c2..bd92d1c6b 100644 --- a/app/assets/javascripts/mobile/mobile_file_uploader.js +++ b/app/assets/javascripts/mobile/mobile_file_uploader.js @@ -35,7 +35,7 @@ function createUploader(){ ); }, - onComplete: function(id, fileName, responseJSON) { + onComplete: function(_id, fileName, responseJSON) { $('#fileInfo-publisher').text(Diaspora.I18n.t("photo_uploader.completed", {'file': fileName})); var id = responseJSON.data.photo.id, url = responseJSON.data.photo.unprocessed_image.url, @@ -67,7 +67,7 @@ function createUploader(){ success: function() { photo.fadeOut(400, function(){ photo.remove(); - if ( $('.publisher_photo').length == 0){ + if ( $('.publisher_photo').length === 0){ $('#publisher_textarea_wrapper').removeClass("with_attachments"); } }); diff --git a/app/assets/javascripts/osmlocator.js b/app/assets/javascripts/osmlocator.js index 8a36dedb3..9a7b59a93 100644 --- a/app/assets/javascripts/osmlocator.js +++ b/app/assets/javascripts/osmlocator.js @@ -16,7 +16,7 @@ OSM.Locator = function(){ function errorGettingPosition(err) { $("#location").remove(); - }; + } return { getAddress: geolocalize diff --git a/app/assets/javascripts/pages/users-getting-started.js b/app/assets/javascripts/pages/users-getting-started.js index fe4d0aa8a..d4f0954ce 100644 --- a/app/assets/javascripts/pages/users-getting-started.js +++ b/app/assets/javascripts/pages/users-getting-started.js @@ -75,7 +75,7 @@ Diaspora.Pages.UsersGettingStarted = function() { autocompleteInput.bind('keydown', function(evt){ 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(); } } diff --git a/app/assets/javascripts/widgets/lightbox.js b/app/assets/javascripts/widgets/lightbox.js index df5bcb628..ef631c1f4 100644 --- a/app/assets/javascripts/widgets/lightbox.js +++ b/app/assets/javascripts/widgets/lightbox.js @@ -94,7 +94,7 @@ jQuery.fn.center = (function() { this.nextImage = function(thumb){ var next = thumb.next(); - if (next.length == 0) { + if (next.length === 0) { next = self.imageset.find("img").first(); } return(next); @@ -102,7 +102,7 @@ jQuery.fn.center = (function() { this.prevImage = function(thumb){ var prev = thumb.prev(); - if (prev.length == 0) { + if (prev.length === 0) { prev = self.imageset.find("img").last(); } return(prev); @@ -132,7 +132,7 @@ jQuery.fn.center = (function() { if(image.attr("data-full-photo") == imageUrl) { imageThumb = thumb; - }; + } self.imageset.append(thumb); }); diff --git a/config/jshint.yml b/config/jshint.yml new file mode 100644 index 000000000..e45c99b31 --- /dev/null +++ b/config/jshint.yml @@ -0,0 +1,44 @@ +files: ['**/*.js'] + +exclude_paths: [ + 'vendor/assets/javascripts', + 'lib/assets/javascripts' +] + +options: + # enforcing options + bitwise: false + camelcase: false + curly: false + eqeqeq: false + forin: true + freeze: true + immed: true + indent: 2 + latedef: nofunc + newcap: false + noarg: true + noempty: true + nonbsp: true + nonew: false + notypeof: true + undef: false + unused: false + + # relaxing options + asi: true + boss: true + eqnull: true + evil: true + expr: true + lastsemic: true + laxbreak: true + laxcomma: true + loopfunc: true + scripturl: true + sub: true + supernew: true + + globals: + jQuery: true + "$": true diff --git a/spec/javascripts/app/helpers/text_formatter_spec.js b/spec/javascripts/app/helpers/text_formatter_spec.js index c9f5750be..0e01004bf 100644 --- a/spec/javascripts/app/helpers/text_formatter_spec.js +++ b/spec/javascripts/app/helpers/text_formatter_spec.js @@ -73,7 +73,7 @@ describe("app.helpers.textFormatter", function(){ it('returns the name of the mention if the mention does not exist in the array', function(){ var text = "hey there @{Chris Smith; chris@example.com}" var formattedText = this.formatter(text, []) - expect(formattedText.match(/\ Date: Sun, 8 Feb 2015 20:50:40 +0100 Subject: [PATCH 2/6] JSHint semicolon errors --- app/assets/javascripts/app/app.js | 21 ++-- .../app/collections/aspect_memberships.js | 2 +- .../javascripts/app/collections/aspects.js | 3 +- .../javascripts/app/collections/comments.js | 5 +- .../javascripts/app/collections/likes.js | 3 +- .../javascripts/app/collections/photos.js | 3 +- .../javascripts/app/helpers/date_formatter.js | 3 +- .../app/helpers/handlebars-helpers.js | 7 +- .../app/helpers/handlebars-partials.js | 3 +- app/assets/javascripts/app/helpers/o_embed.js | 7 +- app/assets/javascripts/app/models/post.js | 32 +++---- .../app/models/post/interactions.js | 57 ++++++----- app/assets/javascripts/app/models/profile.js | 14 +-- app/assets/javascripts/app/models/reshare.js | 6 +- .../javascripts/app/models/status_message.js | 2 +- app/assets/javascripts/app/models/stream.js | 21 ++-- .../javascripts/app/models/stream_aspects.js | 2 +- app/assets/javascripts/app/models/user.js | 4 +- .../app/pages/single-post-viewer.js | 5 +- app/assets/javascripts/app/router.js | 5 +- app/assets/javascripts/app/views.js | 33 ++++--- .../javascripts/app/views/aspect_view.js | 3 +- .../app/views/aspects_list_view.js | 3 +- .../app/views/comment_stream_view.js | 11 +-- .../javascripts/app/views/comment_view.js | 13 ++- .../javascripts/app/views/content_view.js | 19 ++-- .../javascripts/app/views/feedback_view.js | 7 +- app/assets/javascripts/app/views/help_view.js | 3 +- .../javascripts/app/views/hovercard_view.js | 3 +- .../app/views/infinite_stream_view.js | 7 +- .../javascripts/app/views/likes_info_view.js | 5 +- .../javascripts/app/views/photo_viewer.js | 3 +- .../javascripts/app/views/photos_view.js | 5 +- app/assets/javascripts/app/views/post_view.js | 5 +- .../app/views/publisher/uploader_view.js | 3 +- .../javascripts/app/views/publisher_view.js | 7 +- .../single-post-viewer/single_post_actions.js | 8 +- .../single_post_comment_stream.js | 13 ++- .../single_post_content_view.js | 5 +- .../single_post_interactions.js | 7 +- .../app/views/stream_faces_view.js | 7 +- .../app/views/stream_post_views.js | 9 +- .../javascripts/app/views/stream_view.js | 21 ++-- .../app/views/tag_following_action_view.js | 3 +- .../app/views/tag_following_view.js | 3 +- app/assets/javascripts/aspects-dropdown.js | 4 +- app/assets/javascripts/diaspora.js | 6 +- app/assets/javascripts/jsxc.js | 2 +- app/assets/javascripts/mobile/mobile.js | 8 +- app/assets/javascripts/osmlocator.js | 6 +- app/assets/javascripts/view.js | 3 +- app/assets/javascripts/widgets/back-to-top.js | 3 +- app/assets/javascripts/widgets/lightbox.js | 2 +- .../javascripts/widgets/notifications.js | 19 ++-- app/assets/javascripts/widgets/search.js | 3 +- app/assets/javascripts/widgets/timeago.js | 3 +- config/jshint.yml | 2 +- spec/javascripts/app/app_spec.js | 2 +- .../collections/comments_collection_spec.js | 13 ++- .../app/collections/likes_collections_spec.js | 13 ++- .../tag_following_collection_spec.js | 22 ++--- .../app/helpers/date_formatter_spec.js | 19 ++-- .../app/helpers/text_formatter_spec.js | 40 ++++---- .../app/models/post/interacations_spec.js | 10 +- spec/javascripts/app/models/post_spec.js | 52 +++++----- spec/javascripts/app/models/reshare_spec.js | 14 +-- .../app/models/status_message_spec.js | 14 +-- spec/javascripts/app/models/user_spec.js | 11 +-- .../app/views/aspects_list_view_spec.js | 2 +- .../app/views/comment_stream_view_spec.js | 18 ++-- .../app/views/comment_view_spec.js | 84 ++++++++-------- .../app/views/content_view_spec.js | 10 +- .../app/views/feedback_view_spec.js | 95 +++++++++---------- .../javascripts/app/views/header_view_spec.js | 34 +++---- .../app/views/likes_info_view_spec.js | 33 ++++--- .../app/views/location_view_spec.js | 2 +- .../javascripts/app/views/oembed_view_spec.js | 14 +-- .../app/views/open_graph_view_spec.js | 2 +- .../app/views/photo_viewer_spec.js | 18 ++-- spec/javascripts/app/views/poll_view_spec.js | 6 +- .../app/views/publisher_view_spec.js | 38 ++++---- .../app/views/stream_faces_view_spec.js | 62 ++++++------ .../javascripts/app/views/stream_post_spec.js | 68 ++++++------- .../javascripts/app/views/stream_view_spec.js | 2 +- .../views/tag_following_action_view_spec.js | 38 ++++---- spec/javascripts/app/views_spec.js | 76 +++++++-------- spec/javascripts/diaspora-spec.js | 4 +- spec/javascripts/helpers/SpecHelper.js | 20 ++-- spec/javascripts/helpers/factory.js | 34 +++---- spec/javascripts/osmlocator-spec.js | 12 +-- spec/javascripts/rails-spec.js | 4 +- spec/javascripts/widgets/i18n-spec.js | 2 +- .../javascripts/widgets/notifications-spec.js | 2 +- 93 files changed, 651 insertions(+), 711 deletions(-) diff --git a/app/assets/javascripts/app/app.js b/app/assets/javascripts/app/app.js index c353a3c99..d0a6a5158 100644 --- a/app/assets/javascripts/app/app.js +++ b/app/assets/javascripts/app/app.js @@ -36,7 +36,7 @@ var app = { user: function(userAttrs) { if(userAttrs) { return this._user = new app.models.User(userAttrs) } - return this._user || false + return this._user || false; }, initialize: function() { @@ -52,21 +52,21 @@ 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() { @@ -101,8 +101,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 +118,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 +132,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..c6a9254b6 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 @@ -132,4 +132,3 @@ Handlebars.registerHelper('aspectMembershipIndicator', function(contact,in_aspec return html; }); // @license-end - diff --git a/app/assets/javascripts/app/helpers/handlebars-partials.js b/app/assets/javascripts/app/helpers/handlebars-partials.js index 50efeeb64..6f1815229 100644 --- a/app/assets/javascripts/app/helpers/handlebars-partials.js +++ b/app/assets/javascripts/app/helpers/handlebars-partials.js @@ -2,7 +2,6 @@ /* we need to wrap this in a document ready to ensure JST is accessible */ $(function(){ - Handlebars.registerPartial('status-message', HandlebarsTemplates['status-message_tpl']) + Handlebars.registerPartial('status-message', HandlebarsTemplates['status-message_tpl']); }); // @license-end - diff --git a/app/assets/javascripts/app/helpers/o_embed.js b/app/assets/javascripts/app/helpers/o_embed.js index be410c9d3..c09df1798 100644 --- a/app/assets/javascripts/app/helpers/o_embed.js +++ b/app/assets/javascripts/app/helpers/o_embed.js @@ -7,12 +7,11 @@ var data = o_embed_cache.data; if (data.type == "photo") { - return '' + return ''; } else { - return data.html || "" + return data.html || ""; } } - } + }; })(); // @license-end - diff --git a/app/assets/javascripts/app/models/post.js b/app/assets/javascripts/app/models/post.js index d2aa388db..73d9de467 100644 --- a/app/assets/javascripts/app/models/post.js +++ b/app/assets/javascripts/app/models/post.js @@ -4,17 +4,17 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin, urlRoot : "/posts", initialize : function() { - this.interactions = new app.models.Post.Interactions(_.extend({post : this}, this.get("interactions"))) - this.delegateToInteractions() + this.interactions = new app.models.Post.Interactions(_.extend({post : this}, this.get("interactions"))); + this.delegateToInteractions(); }, delegateToInteractions : function(){ - this.comments = this.interactions.comments - this.likes = this.interactions.likes + this.comments = this.interactions.comments; + this.likes = this.interactions.likes; this.comment = function(){ - this.interactions.comment.apply(this.interactions, arguments) - } + this.interactions.comment.apply(this.interactions, arguments); + }; }, interactedAt : function() { @@ -26,7 +26,7 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin, }, reshareAuthor : function(){ - return this.get("author") + return this.get("author"); }, blockAuthor: function() { @@ -38,7 +38,7 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin, }, toggleFavorite : function(options){ - this.set({favorite : !this.get("favorite")}) + this.set({favorite : !this.get("favorite")}); /* guard against attempting to save a model that a user doesn't own */ if(options.save){ this.save() } @@ -46,28 +46,28 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin, headline : function() { var headline = this.get("text").trim() - , newlineIdx = headline.indexOf("\n") - return (newlineIdx > 0 ) ? headline.substr(0, newlineIdx) : headline + , newlineIdx = headline.indexOf("\n"); + return (newlineIdx > 0 ) ? headline.substr(0, newlineIdx) : headline; }, body : function(){ var body = this.get("text").trim() - , newlineIdx = body.indexOf("\n") - return (newlineIdx > 0 ) ? body.substr(newlineIdx+1, body.length) : "" + , newlineIdx = body.indexOf("\n"); + return (newlineIdx > 0 ) ? body.substr(newlineIdx+1, body.length) : ""; }, //returns a promise preloadOrFetch : function(){ - var action = app.hasPreload("post") ? this.set(app.parsePreload("post")) : this.fetch() - return $.when(action) + var action = app.hasPreload("post") ? this.set(app.parsePreload("post")) : this.fetch(); + return $.when(action); }, hasPhotos : function(){ - return this.get("photos") && this.get("photos").length > 0 + return this.get("photos") && this.get("photos").length > 0; }, hasText : function(){ - return $.trim(this.get("text")) !== "" + return $.trim(this.get("text")) !== ""; } })); // @license-end diff --git a/app/assets/javascripts/app/models/post/interactions.js b/app/assets/javascripts/app/models/post/interactions.js index 3c188188c..b9e56f169 100644 --- a/app/assets/javascripts/app/models/post/interactions.js +++ b/app/assets/javascripts/app/models/post/interactions.js @@ -4,80 +4,80 @@ app.models.Post.Interactions = Backbone.Model.extend({ url : function(){ - return this.post.url() + "/interactions" + return this.post.url() + "/interactions"; }, initialize : function(options){ - this.post = options.post - this.comments = new app.collections.Comments(this.get("comments"), {post : this.post}) + this.post = options.post; + this.comments = new app.collections.Comments(this.get("comments"), {post : this.post}); this.likes = new app.collections.Likes(this.get("likes"), {post : this.post}); this.reshares = new app.collections.Reshares(this.get("reshares"), {post : this.post}); }, parse : function(resp){ - this.comments.reset(resp.comments) - this.likes.reset(resp.likes) - this.reshares.reset(resp.reshares) + this.comments.reset(resp.comments); + this.likes.reset(resp.likes); + this.reshares.reset(resp.reshares); var comments = this.comments , likes = this.likes - , reshares = this.reshares + , reshares = this.reshares; return { comments : comments, likes : likes, reshares : reshares, fetched : true - } + }; }, likesCount : function(){ - return (this.get("fetched") ? this.likes.models.length : this.get("likes_count") ) + return (this.get("fetched") ? this.likes.models.length : this.get("likes_count") ); }, resharesCount : function(){ - return this.get("fetched") ? this.reshares.models.length : this.get("reshares_count") + return this.get("fetched") ? this.reshares.models.length : this.get("reshares_count"); }, commentsCount : function(){ - return this.get("fetched") ? this.comments.models.length : this.get("comments_count") + return this.get("fetched") ? this.comments.models.length : this.get("comments_count"); }, userLike : function(){ - return this.likes.select(function(like){ return like.get("author").guid == app.currentUser.get("guid")})[0] + return this.likes.select(function(like){ return like.get("author").guid == app.currentUser.get("guid")})[0]; }, userReshare : function(){ return this.reshares.select(function(reshare){ - return reshare.get("author") && reshare.get("author").guid == app.currentUser.get("guid")})[0] + return reshare.get("author") && reshare.get("author").guid == app.currentUser.get("guid")})[0]; }, toggleLike : function() { if(this.userLike()) { - this.unlike() + this.unlike(); } else { - this.like() + this.like(); } }, like : function() { var self = this; this.likes.create({}, {success : function(){ - self.trigger("change") - self.set({"likes_count" : self.get("likes_count") + 1}) - }}) + self.trigger("change"); + self.set({"likes_count" : self.get("likes_count") + 1}); + }}); - app.instrument("track", "Like") + app.instrument("track", "Like"); }, unlike : function() { var self = this; this.userLike().destroy({success : function(model, resp) { - self.trigger('change') - self.set({"likes_count" : self.get("likes_count") - 1}) + self.trigger('change'); + self.set({"likes_count" : self.get("likes_count") - 1}); }}); - app.instrument("track", "Unlike") + app.instrument("track", "Unlike"); }, comment : function (text) { @@ -90,12 +90,12 @@ app.models.Post.Interactions = Backbone.Model.extend({ notice: Diaspora.I18n.t("failed_to_post_message") }); }).done(function() { - self.trigger('change') //updates after sync + self.trigger('change'); //updates after sync }); - this.trigger("change") //updates count in an eager manner + this.trigger("change"); //updates count in an eager manner - app.instrument("track", "Comment") + app.instrument("track", "Comment"); }, reshare : function(){ @@ -117,12 +117,12 @@ app.models.Post.Interactions = Backbone.Model.extend({ }); } }).done(function(){ - interactions.reshares.add(reshare) + interactions.reshares.add(reshare); }).done(function(){ - interactions.trigger("change") + interactions.trigger("change"); }); - app.instrument("track", "Reshare") + app.instrument("track", "Reshare"); }, userCanReshare : function(){ @@ -137,4 +137,3 @@ app.models.Post.Interactions = Backbone.Model.extend({ } }); // @license-end - diff --git a/app/assets/javascripts/app/models/profile.js b/app/assets/javascripts/app/models/profile.js index 0039e3518..59c543145 100644 --- a/app/assets/javascripts/app/models/profile.js +++ b/app/assets/javascripts/app/models/profile.js @@ -5,19 +5,19 @@ app.models.Profile = Backbone.Model.extend({ }, { preloadOrFetch : function(id){ - return app.hasPreload("person") ? this.preload() : this.findByGuid(id) + return app.hasPreload("person") ? this.preload() : this.findByGuid(id); }, preload : function(){ - var person = new app.models.Profile(app.parsePreload("person")) - person.deferred = $.when(true) - return person + var person = new app.models.Profile(app.parsePreload("person")); + person.deferred = $.when(true); + return person; }, findByGuid : function(personId){ - var person = new app.models.Profile({ id : personId}) - person.deferred = person.fetch() - return person + var person = new app.models.Profile({ id : personId}); + person.deferred = person.fetch(); + return person; } }); // @license-end diff --git a/app/assets/javascripts/app/models/reshare.js b/app/assets/javascripts/app/models/reshare.js index 9fd9de3df..a236f2384 100644 --- a/app/assets/javascripts/app/models/reshare.js +++ b/app/assets/javascripts/app/models/reshare.js @@ -5,15 +5,15 @@ app.models.Reshare = app.models.Post.extend({ rootPost : function(){ this._rootPost = this._rootPost || new app.models.Post(this.get("root")); - return this._rootPost + return this._rootPost; }, reshare : function(){ - return this.rootPost().reshare() + return this.rootPost().reshare(); }, reshareAuthor : function(){ - return this.rootPost().reshareAuthor() + return this.rootPost().reshareAuthor(); } }); // @license-end diff --git a/app/assets/javascripts/app/models/status_message.js b/app/assets/javascripts/app/models/status_message.js index 317b4adc6..f8469662a 100644 --- a/app/assets/javascripts/app/models/status_message.js +++ b/app/assets/javascripts/app/models/status_message.js @@ -17,7 +17,7 @@ app.models.StatusMessage = app.models.Post.extend({ photos : this.photos && this.photos.pluck("id"), services : this.get("services"), poll : this.get("poll") - } + }; } }); // @license-end diff --git a/app/assets/javascripts/app/models/stream.js b/app/assets/javascripts/app/models/stream.js index 54a51a747..f66cc0686 100644 --- a/app/assets/javascripts/app/models/stream.js +++ b/app/assets/javascripts/app/models/stream.js @@ -4,7 +4,7 @@ //= require ../collections/photos app.models.Stream = Backbone.Collection.extend({ initialize : function(models, options){ - var collectionClass = app.collections.Posts + var collectionClass = app.collections.Posts; if( options ) { options.collection && (collectionClass = options.collection); options.basePath && (this.streamPath = options.basePath); @@ -14,11 +14,11 @@ app.models.Stream = Backbone.Collection.extend({ collectionOptions :function(){ var order = this.sortOrder(); - return { comparator : function(item) { return -item[order](); } } + return { comparator : function(item) { return -item[order](); } }; }, url : function(){ - return _.any(this.items.models) ? this.timeFilteredPath() : this.basePath() + return _.any(this.items.models) ? this.timeFilteredPath() : this.basePath(); }, _fetchOpts: function(opts) { @@ -57,11 +57,11 @@ app.models.Stream = Backbone.Collection.extend({ maxTime: function(){ var lastPost = _.last(this.items.models); - return lastPost[this.sortOrder()]() + return lastPost[this.sortOrder()](); }, sortOrder : function() { - return this.basePath().match(/activity/) ? "interactedAt" : "createdAt" + return this.basePath().match(/activity/) ? "interactedAt" : "createdAt"; }, /* This function is for adding a large number of posts one by one. @@ -71,7 +71,7 @@ app.models.Stream = Backbone.Collection.extend({ * stream for the changes to take effect in the infinite stream view */ add : function(models){ - this.items.add(models) + this.items.add(models); }, /* This function is for adding a single post. It immediately triggers @@ -84,14 +84,13 @@ app.models.Stream = Backbone.Collection.extend({ }, preloadOrFetch : function(){ //hai, plz test me THNX - return $.when(app.hasPreload("stream") ? this.preload() : this.fetch()) + return $.when(app.hasPreload("stream") ? this.preload() : this.fetch()); }, preload : function(){ - this.items.reset(app.parsePreload("stream")) - this.deferred = $.when(true) - this.trigger("fetched") + this.items.reset(app.parsePreload("stream")); + this.deferred = $.when(true); + this.trigger("fetched"); } }); // @license-end - diff --git a/app/assets/javascripts/app/models/stream_aspects.js b/app/assets/javascripts/app/models/stream_aspects.js index a0115887d..e64d3ea5b 100644 --- a/app/assets/javascripts/app/models/stream_aspects.js +++ b/app/assets/javascripts/app/models/stream_aspects.js @@ -3,7 +3,7 @@ app.models.StreamAspects = app.models.Stream.extend({ url : function(){ - return _.any(this.items.models) ? this.timeFilteredPath() : this.basePath() + return _.any(this.items.models) ? this.timeFilteredPath() : this.basePath(); }, initialize : function(models, options){ diff --git a/app/assets/javascripts/app/models/user.js b/app/assets/javascripts/app/models/user.js index 98dc67c01..df8974ff0 100644 --- a/app/assets/javascripts/app/models/user.js +++ b/app/assets/javascripts/app/models/user.js @@ -12,11 +12,11 @@ app.models.User = Backbone.Model.extend({ }, expProfileUrl : function(){ - return "/people/" + app.currentUser.get("guid") + "?ex=true" + return "/people/" + app.currentUser.get("guid") + "?ex=true"; }, isServiceConfigured : function(providerName) { - return _.include(this.get("configured_services"), providerName) + return _.include(this.get("configured_services"), providerName); }, isAuthorOf: function(model) { diff --git a/app/assets/javascripts/app/pages/single-post-viewer.js b/app/assets/javascripts/app/pages/single-post-viewer.js index b5af389b3..c0b5f6bf9 100644 --- a/app/assets/javascripts/app/pages/single-post-viewer.js +++ b/app/assets/javascripts/app/pages/single-post-viewer.js @@ -11,8 +11,8 @@ app.pages.SinglePostViewer = app.views.Base.extend({ initialize : function(options) { this.model = new app.models.Post({ id : options.id }); this.model.preloadOrFetch().done(_.bind(this.initViews, this)); - this.model.interactions.fetch() //async, yo, might want to throttle this later. - this.setupLightbox() + this.model.interactions.fetch(); //async, yo, might want to throttle this later. + this.setupLightbox(); }, setupLightbox : function(){ @@ -41,4 +41,3 @@ app.pages.SinglePostViewer = app.views.Base.extend({ }); // @license-end - diff --git a/app/assets/javascripts/app/router.js b/app/assets/javascripts/app/router.js index 76398707c..4e5e6d36c 100644 --- a/app/assets/javascripts/app/router.js +++ b/app/assets/javascripts/app/router.js @@ -113,7 +113,7 @@ app.Router = Backbone.Router.extend({ var followedTagsAction = new app.views.TagFollowingAction( {tagText: decodeURIComponent(name).toLowerCase()} ); - $("#author_info").prepend(followedTagsAction.render().el) + $("#author_info").prepend(followedTagsAction.render().el); app.tags = new app.views.Tags({tagName: name}); } this._hideInactiveStreamLists(); @@ -151,7 +151,7 @@ app.Router = Backbone.Router.extend({ }, bookmarklet: function() { - var contents = (window.gon) ? gon.preloads.bookmarklet : {} + var contents = (window.gon) ? gon.preloads.bookmarklet : {}; app.bookmarklet = new app.views.Bookmarklet( _.extend({}, {el: $('#bookmarklet')}, contents) ).render(); @@ -164,4 +164,3 @@ app.Router = Backbone.Router.extend({ } }); // @license-end - diff --git a/app/assets/javascripts/app/views.js b/app/assets/javascripts/app/views.js index a677e54d4..ef7f82533 100644 --- a/app/assets/javascripts/app/views.js +++ b/app/assets/javascripts/app/views.js @@ -7,7 +7,7 @@ app.views.Base = Backbone.View.extend({ }, presenter : function(){ - return this.defaultPresenter() + return this.defaultPresenter(); }, setupRenderEvents : function(){ @@ -18,7 +18,7 @@ app.views.Base = Backbone.View.extend({ }, defaultPresenter : function(){ - var modelJson = this.model && this.model.attributes ? _.clone(this.model.attributes) : {} + var modelJson = this.model && this.model.attributes ? _.clone(this.model.attributes) : {}; return _.extend(modelJson, { current_user : app.currentUser.attributes, @@ -27,19 +27,19 @@ app.views.Base = Backbone.View.extend({ }, render : function() { - this.renderTemplate() - this.renderSubviews() - this.renderPluginWidgets() - this.removeTooltips() + this.renderTemplate(); + this.renderSubviews(); + this.renderPluginWidgets(); + this.removeTooltips(); - return this + return this; }, renderTemplate : function(){ - var presenter = _.isFunction(this.presenter) ? this.presenter() : this.presenter - this.template = HandlebarsTemplates[this.templateName+"_tpl"] + var presenter = _.isFunction(this.presenter) ? this.presenter() : this.presenter; + this.template = HandlebarsTemplates[this.templateName+"_tpl"]; if(!this.template) { - console.log(this.templateName ? ("no template for " + this.templateName) : "no templateName specified") + console.log(this.templateName ? ("no template for " + this.templateName) : "no templateName specified"); return; } @@ -58,12 +58,12 @@ app.views.Base = Backbone.View.extend({ renderSubviews : function(){ var self = this; _.each(this.subviews, function(property, selector){ - var view = _.isFunction(self[property]) ? self[property]() : self[property] + var view = _.isFunction(self[property]) ? self[property]() : self[property]; if(view) { - self.$(selector).html(view.render().el) + self.$(selector).html(view.render().el); view.delegateEvents(); } - }) + }); }, renderPluginWidgets : function() { @@ -76,15 +76,15 @@ app.views.Base = Backbone.View.extend({ }, setFormAttrs : function(){ - this.model.set(_.inject(this.formAttrs, _.bind(setValueFromField, this), {})) + this.model.set(_.inject(this.formAttrs, _.bind(setValueFromField, this), {})); function setValueFromField(memo, attribute, selector){ if(attribute.slice("-2") === "[]") { - memo[attribute.slice(0, attribute.length - 2)] = _.pluck(this.$el.find(selector).serializeArray(), "value") + memo[attribute.slice(0, attribute.length - 2)] = _.pluck(this.$el.find(selector).serializeArray(), "value"); } else { memo[attribute] = this.$el.find(selector).val() || this.$el.find(selector).text(); } - return memo + return memo; } }, @@ -163,4 +163,3 @@ app.views.StaticContentView = app.views.Base.extend({ }, }); // @license-end - diff --git a/app/assets/javascripts/app/views/aspect_view.js b/app/assets/javascripts/app/views/aspect_view.js index 4d986ee9d..3fba4865c 100644 --- a/app/assets/javascripts/app/views/aspect_view.js +++ b/app/assets/javascripts/app/views/aspect_view.js @@ -21,8 +21,7 @@ app.views.Aspect = app.views.Base.extend({ presenter : function() { return _.extend(this.defaultPresenter(), { aspect : this.model - }) + }); } }); // @license-end - diff --git a/app/assets/javascripts/app/views/aspects_list_view.js b/app/assets/javascripts/app/views/aspects_list_view.js index 61f671645..6af4d41cc 100644 --- a/app/assets/javascripts/app/views/aspects_list_view.js +++ b/app/assets/javascripts/app/views/aspects_list_view.js @@ -68,6 +68,5 @@ app.views.AspectsList = app.views.Base.extend({ hideAspectsList: function() { this.$el.empty(); }, -}) +}); // @license-end - diff --git a/app/assets/javascripts/app/views/comment_stream_view.js b/app/assets/javascripts/app/views/comment_stream_view.js index 32c349e8b..c694f1cac 100644 --- a/app/assets/javascripts/app/views/comment_stream_view.js +++ b/app/assets/javascripts/app/views/comment_stream_view.js @@ -39,7 +39,7 @@ app.views.CommentStream = app.views.Base.extend({ moreCommentsCount : (this.model.interactions.commentsCount() - 3), showExpandCommentsLink : (this.model.interactions.commentsCount() > 3), commentsCount : this.model.interactions.commentsCount() - }) + }); }, createComment: function(evt) { @@ -58,7 +58,7 @@ app.views.CommentStream = app.views.Base.extend({ keyDownOnCommentBox: function(evt) { if(evt.keyCode == 13 && evt.ctrlKey) { - this.$("form").submit() + this.$("form").submit(); return false; } }, @@ -66,7 +66,7 @@ app.views.CommentStream = app.views.Base.extend({ 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.Comment({ model: comment @@ -91,12 +91,11 @@ app.views.CommentStream = app.views.Base.extend({ self.model.set({ comments : resp.models, all_comments_loaded : true - }) + }); - self.model.trigger("commentsExpanded", self) + self.model.trigger("commentsExpanded", self); } }); } }); // @license-end - diff --git a/app/assets/javascripts/app/views/comment_view.js b/app/assets/javascripts/app/views/comment_view.js index f99bd7f66..ca9965c66 100644 --- a/app/assets/javascripts/app/views/comment_view.js +++ b/app/assets/javascripts/app/views/comment_view.js @@ -13,27 +13,27 @@ app.views.Comment = app.views.Content.extend({ }, initialize : function(options){ - this.templateName = options.templateName || this.templateName - this.model.on("change", this.render, this) + this.templateName = options.templateName || this.templateName; + this.model.on("change", this.render, this); }, presenter : function() { return _.extend(this.defaultPresenter(), { canRemove: this.canRemove(), text : app.helpers.textFormatter(this.model.get("text")) - }) + }); }, ownComment : function() { - return app.currentUser.authenticated() && this.model.get("author").diaspora_id == app.currentUser.get("diaspora_id") + return app.currentUser.authenticated() && this.model.get("author").diaspora_id == app.currentUser.get("diaspora_id"); }, postOwner : function() { - return app.currentUser.authenticated() && this.model.get("parent").author.diaspora_id == app.currentUser.get("diaspora_id") + return app.currentUser.authenticated() && this.model.get("parent").author.diaspora_id == app.currentUser.get("diaspora_id"); }, canRemove : function() { - return app.currentUser.authenticated() && (this.ownComment() || this.postOwner()) + return app.currentUser.authenticated() && (this.ownComment() || this.postOwner()); } }); @@ -42,4 +42,3 @@ app.views.ExpandedComment = app.views.Comment.extend({ } }); // @license-end - diff --git a/app/assets/javascripts/app/views/content_view.js b/app/assets/javascripts/app/views/content_view.js index 71c641141..13816e34e 100644 --- a/app/assets/javascripts/app/views/content_view.js +++ b/app/assets/javascripts/app/views/content_view.js @@ -16,13 +16,13 @@ app.views.Content = app.views.Base.extend({ largePhoto : function() { - var photos = this.model.get("photos") + var photos = this.model.get("photos"); if(!photos || photos.length === 0) { return } - return photos[0] + return photos[0]; }, smallPhotos : function() { - var photos = this.model.get("photos") + var photos = this.model.get("photos"); if(!photos || photos.length < 2) { return } photos.splice(0, 1); // remove first photo as it is already shown as largePhoto return photos; @@ -71,7 +71,7 @@ app.views.Content = app.views.Base.extend({ }, postRenderTemplate : function(){ - _.defer(_.bind(this.collapseOversized, this)) + _.defer(_.bind(this.collapseOversized, this)); } }); @@ -95,15 +95,15 @@ app.views.OEmbed = app.views.Base.extend({ }, presenter:function () { - o_embed_cache = this.model.get("o_embed_cache") + o_embed_cache = this.model.get("o_embed_cache"); if(o_embed_cache) { - typemodel = { rich: false, photo: false, video: false, link: false } - typemodel[o_embed_cache.data.type] = true - o_embed_cache.data.types = typemodel + typemodel = { rich: false, photo: false, video: false, link: false }; + typemodel[o_embed_cache.data.type] = true; + o_embed_cache.data.types = typemodel; } return _.extend(this.defaultPresenter(), { o_embed_html : app.helpers.oEmbed.html(o_embed_cache) - }) + }); }, showOembedContent : function (evt) { @@ -137,4 +137,3 @@ app.views.SPVOpenGraph = app.views.OpenGraph.extend({ } }); // @license-end - diff --git a/app/assets/javascripts/app/views/feedback_view.js b/app/assets/javascripts/app/views/feedback_view.js index 200a11830..938469bbb 100644 --- a/app/assets/javascripts/app/views/feedback_view.js +++ b/app/assets/javascripts/app/views/feedback_view.js @@ -18,11 +18,11 @@ app.views.Feedback = app.views.Base.extend({ initialize : function() { this.model.interactions.on('change', this.render, this); - this.initViews && this.initViews() // I don't know why this was failing with $.noop... :( + this.initViews && this.initViews(); // I don't know why this was failing with $.noop... :( }, presenter : function() { - var interactions = this.model.interactions + var interactions = this.model.interactions; return _.extend(this.defaultPresenter(),{ commentsCount : interactions.commentsCount(), @@ -31,7 +31,7 @@ app.views.Feedback = app.views.Base.extend({ userCanReshare : interactions.userCanReshare(), userLike : interactions.userLike(), userReshare : interactions.userReshare() - }) + }); }, toggleLike: function(evt) { @@ -85,4 +85,3 @@ app.views.Feedback = app.views.Base.extend({ }, }); // @license-end - diff --git a/app/assets/javascripts/app/views/help_view.js b/app/assets/javascripts/app/views/help_view.js index fa93966a0..c2c586adf 100644 --- a/app/assets/javascripts/app/views/help_view.js +++ b/app/assets/javascripts/app/views/help_view.js @@ -52,7 +52,7 @@ app.views.Help = app.views.StaticContentView.extend({ title_tags: Diaspora.I18n.t( 'tags.title' ), title_keyboard_shortcuts: Diaspora.I18n.t( 'keyboard_shortcuts.title' ), title_miscellaneous: Diaspora.I18n.t( 'miscellaneous.title' ), - } + }; return this; }, @@ -173,4 +173,3 @@ app.views.Help = app.views.StaticContentView.extend({ }, }); // @license-end - diff --git a/app/assets/javascripts/app/views/hovercard_view.js b/app/assets/javascripts/app/views/hovercard_view.js index e4497b18a..b113e2ce6 100644 --- a/app/assets/javascripts/app/views/hovercard_view.js +++ b/app/assets/javascripts/app/views/hovercard_view.js @@ -29,7 +29,7 @@ app.views.Hovercard = app.views.Base.extend({ }, postRenderTemplate: function() { - this.$el.appendTo($('body')) + this.$el.appendTo($('body')); }, deactivate: function() { @@ -143,4 +143,3 @@ app.views.Hovercard = app.views.Base.extend({ } }); // @license-end - diff --git a/app/assets/javascripts/app/views/infinite_stream_view.js b/app/assets/javascripts/app/views/infinite_stream_view.js index 59e493ee6..8e755a7f4 100644 --- a/app/assets/javascripts/app/views/infinite_stream_view.js +++ b/app/assets/javascripts/app/views/infinite_stream_view.js @@ -58,7 +58,7 @@ app.views.InfScroll = app.views.Base.extend({ }, renderTemplate : function(){ - this.renderInitialPosts() + this.renderInitialPosts(); }, renderInitialPosts : function(){ @@ -66,7 +66,7 @@ app.views.InfScroll = app.views.Base.extend({ var els = document.createDocumentFragment(); this.stream.items.each(_.bind(function(post){ els.appendChild(this.createPostView(post).render().el); - }, this)) + }, this)); this.$el.html(els); }, @@ -78,7 +78,7 @@ app.views.InfScroll = app.views.Base.extend({ }, showLoader: function(){ - $("#paginate .loader").removeClass("hidden") + $("#paginate .loader").removeClass("hidden"); }, finishedAdding: function() { @@ -108,4 +108,3 @@ app.views.InfScroll = app.views.Base.extend({ } }); // @license-end - diff --git a/app/assets/javascripts/app/views/likes_info_view.js b/app/assets/javascripts/app/views/likes_info_view.js index b85be03ed..a672645dd 100644 --- a/app/assets/javascripts/app/views/likes_info_view.js +++ b/app/assets/javascripts/app/views/likes_info_view.js @@ -19,13 +19,12 @@ app.views.LikesInfo = app.views.Base.extend({ likes : this.model.interactions.likes.toJSON(), likesCount : this.model.interactions.likesCount(), likes_fetched : this.model.interactions.get("fetched"), - }) + }); }, showAvatars : function(evt){ if(evt) { evt.preventDefault() } - this.model.interactions.fetch() + this.model.interactions.fetch(); } }); // @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..2870f6446 100644 --- a/app/assets/javascripts/app/views/photos_view.js +++ b/app/assets/javascripts/app/views/photos_view.js @@ -8,8 +8,8 @@ app.views.Photos = app.views.InfScroll.extend({ // 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/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/publisher/uploader_view.js b/app/assets/javascripts/app/views/publisher/uploader_view.js index 302d6c335..b8218fed9 100644 --- a/app/assets/javascripts/app/views/publisher/uploader_view.js +++ b/app/assets/javascripts/app/views/publisher/uploader_view.js @@ -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'); @@ -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 79443d1ec..86143412e 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -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() + _this.tryClose(); } }); @@ -406,7 +406,7 @@ app.views.Publisher = Backbone.View.extend({ tryClose : function(){ // if it is not submittable, close it. if( !this._submittable() ){ - this.close() + this.close(); } }, @@ -509,4 +509,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..4aa89f199 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..497a8e83a 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 @@ -19,15 +19,15 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({ }, 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/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..940b5a401 100644 --- a/app/assets/javascripts/app/views/stream_view.js +++ b/app/assets/javascripts/app/views/stream_view.js @@ -6,16 +6,16 @@ app.views.Stream = app.views.InfScroll.extend(_.extend( app.views.StreamShortcuts, { initialize: function(options) { - this.stream = this.model - this.collection = this.stream.items + 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,10 +26,10 @@ app.views.Stream = app.views.InfScroll.extend(_.extend( }, setupNSFW : function(){ - app.currentUser.bind("nsfwChanged", reRenderPostViews, this) + app.currentUser.bind("nsfwChanged", reRenderPostViews, this); function reRenderPostViews() { - _.map(this.postViews, function(view){ view.render() }) + _.map(this.postViews, function(view){ view.render() }); } }, @@ -41,4 +41,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..3475bc545 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() { @@ -63,4 +63,3 @@ app.views.TagFollowingAction = 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/aspects-dropdown.js b/app/assets/javascripts/aspects-dropdown.js index fceb73af8..ef01bd769 100644 --- a/app/assets/javascripts/aspects-dropdown.js +++ b/app/assets/javascripts/aspects-dropdown.js @@ -34,7 +34,7 @@ var AspectsDropdown = { 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 @@ -75,6 +75,4 @@ var AspectsDropdown = { }); } }; - // @license-end - diff --git a/app/assets/javascripts/diaspora.js b/app/assets/javascripts/diaspora.js index ea469b90f..de5a97900 100644 --- a/app/assets/javascripts/diaspora.js +++ b/app/assets/javascripts/diaspora.js @@ -89,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/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 6354b6bd2..9e64978e9 100644 --- a/app/assets/javascripts/mobile/mobile.js +++ b/app/assets/javascripts/mobile/mobile.js @@ -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'); @@ -253,7 +253,7 @@ $(document).ready(function(){ comments.html(data); container.append(comments); form.remove(); - container.appendTo(bottomBar) + container.appendTo(bottomBar); } reactionLink.text(reactionLink.text().replace(/(\d+)/, function(match){ return parseInt(match) + 1; })); @@ -302,6 +302,4 @@ $(document).ready(function(){ }); }); - // @license-end - diff --git a/app/assets/javascripts/osmlocator.js b/app/assets/javascripts/osmlocator.js index 9a7b59a93..e5517b768 100644 --- a/app/assets/javascripts/osmlocator.js +++ b/app/assets/javascripts/osmlocator.js @@ -20,8 +20,6 @@ OSM.Locator = function(){ return { getAddress: geolocalize - } - -} + }; +}; // @license-end - diff --git a/app/assets/javascripts/view.js b/app/assets/javascripts/view.js index a833bd035..9ce4e6a90 100644 --- a/app/assets/javascripts/view.js +++ b/app/assets/javascripts/view.js @@ -63,7 +63,7 @@ var View = { }); $("a.new_aspect").click(function(e){ - $("input#aspect_name").focus() + $("input#aspect_name").focus(); }); /* facebox 'done' buttons */ @@ -111,4 +111,3 @@ $(function() { View.initialize(); }); // @license-end - diff --git a/app/assets/javascripts/widgets/back-to-top.js b/app/assets/javascripts/widgets/back-to-top.js index dd569728e..bde326774 100644 --- a/app/assets/javascripts/widgets/back-to-top.js +++ b/app/assets/javascripts/widgets/back-to-top.js @@ -27,11 +27,10 @@ (self.body.scrollTop() > 1000) ? 'addClass' : 'removeClass' - ]('visible') + ]('visible'); }; }; Diaspora.Widgets.BackToTop = BackToTop; })(); // @license-end - diff --git a/app/assets/javascripts/widgets/lightbox.js b/app/assets/javascripts/widgets/lightbox.js index ef631c1f4..b2b91922b 100644 --- a/app/assets/javascripts/widgets/lightbox.js +++ b/app/assets/javascripts/widgets/lightbox.js @@ -154,7 +154,7 @@ jQuery.fn.center = (function() { this.scrollToThumbnail = function(imageThumb) { self.navigation.animate({scrollLeft: (self.navigation.scrollLeft() + imageThumb.offset().left +35 - (self.window.width() / 2))}, 200, 'swing'); - } + }; this.selectImage = function(imageThumb) { $(".selected", self.imageset).removeClass("selected"); diff --git a/app/assets/javascripts/widgets/notifications.js b/app/assets/javascripts/widgets/notifications.js index 46108f8de..226788bfe 100644 --- a/app/assets/javascripts/widgets/notifications.js +++ b/app/assets/javascripts/widgets/notifications.js @@ -41,7 +41,7 @@ }); this.setUpNotificationPage = function( page ) { self.notificationPage = page; - } + }; this.unreadClick = function() { $.ajax({ url: "/notifications/" + $(this).closest(".stream_element,.notification_element").data("guid"), @@ -68,7 +68,7 @@ .removeAttr('data-original-title') .attr('title', Diaspora.I18n.t('notifications.mark_read')) .tooltip(); - } + }; this.setUpRead = function( an_obj ) { an_obj.removeClass("unread").addClass( "read" ); an_obj.find('.unread-toggle') @@ -79,17 +79,17 @@ .removeAttr('data-original-title') .attr('title', Diaspora.I18n.t('notifications.mark_unread')) .tooltip(); - } + }; this.clickSuccess = function( data ) { - var itemID = data["guid"] - var isUnread = data["unread"] + var itemID = data["guid"]; + var isUnread = data["unread"]; self.notificationMenu.find('.read,.unread').each(function(index) { if ( $(this).data("guid") == itemID ) { if ( isUnread ) { - self.notificationMenu.find('a#mark_all_read_link').removeClass('disabled') - self.setUpUnread( $(this) ) + self.notificationMenu.find('a#mark_all_read_link').removeClass('disabled'); + self.setUpUnread( $(this) ); } else { - self.setUpRead( $(this) ) + self.setUpRead( $(this) ); } } }); @@ -118,7 +118,7 @@ }; this.changeNotificationCount = function(change) { - self.count = Math.max( self.count + change, 0 ) + self.count = Math.max( self.count + change, 0 ); self.badge.text(self.count); if(self.count === 0) { @@ -145,4 +145,3 @@ Diaspora.Widgets.Notifications = Notifications; })(); // @license-end - diff --git a/app/assets/javascripts/widgets/search.js b/app/assets/javascripts/widgets/search.js index ee21be3a6..554075194 100644 --- a/app/assets/javascripts/widgets/search.js +++ b/app/assets/javascripts/widgets/search.js @@ -53,7 +53,7 @@ this.parse = function(data) { var results = data.map(function(person){ person['name'] = Handlebars.Utils.escapeExpression(person['name']); - return {data : person, value : person['name']} + return {data : person, value : person['name']}; }); results.push({ @@ -81,4 +81,3 @@ Diaspora.Widgets.Search = Search; })(); // @license-end - diff --git a/app/assets/javascripts/widgets/timeago.js b/app/assets/javascripts/widgets/timeago.js index 0e33217f0..e6146781a 100644 --- a/app/assets/javascripts/widgets/timeago.js +++ b/app/assets/javascripts/widgets/timeago.js @@ -11,7 +11,7 @@ this.subscribe("widget/ready", function() { if(Diaspora.I18n.language !== "en") { $.timeago.settings.lang = Diaspora.I18n.language; - $.timeago.settings.strings[Diaspora.I18n.language] = {} + $.timeago.settings.strings[Diaspora.I18n.language] = {}; $.each($.timeago.settings.strings["en"], function(index) { if(index == "numbers") { $.timeago.settings.strings[Diaspora.I18n.language][index] = []; @@ -25,4 +25,3 @@ }; })(); // @license-end - diff --git a/config/jshint.yml b/config/jshint.yml index e45c99b31..ae1bae9b0 100644 --- a/config/jshint.yml +++ b/config/jshint.yml @@ -26,7 +26,7 @@ options: unused: false # relaxing options - asi: true + asi: false boss: true eqnull: true evil: true diff --git a/spec/javascripts/app/app_spec.js b/spec/javascripts/app/app_spec.js index e5f396fd1..2840c1d31 100644 --- a/spec/javascripts/app/app_spec.js +++ b/spec/javascripts/app/app_spec.js @@ -6,7 +6,7 @@ describe("app", function() { }); it("sets the user if given one and returns the current user", function() { - expect(app.user()).toBeFalsy() + expect(app.user()).toBeFalsy(); app.user({name: "alice"}); expect(app.user().get("name")).toEqual("alice"); }); diff --git a/spec/javascripts/app/collections/comments_collection_spec.js b/spec/javascripts/app/collections/comments_collection_spec.js index 76f6498e9..0e8c3ddf5 100644 --- a/spec/javascripts/app/collections/comments_collection_spec.js +++ b/spec/javascripts/app/collections/comments_collection_spec.js @@ -1,10 +1,9 @@ describe("app.collections.comments", function(){ describe("url", function(){ it("should user the post id", function(){ - var post =new app.models.Post({id : 5}) - var collection = new app.collections.Comments([], {post : post}) - expect(collection.url()).toBe("/posts/5/comments") - }) - }) -}) - + var post =new app.models.Post({id : 5}); + var collection = new app.collections.Comments([], {post : post}); + expect(collection.url()).toBe("/posts/5/comments"); + }); + }); +}); diff --git a/spec/javascripts/app/collections/likes_collections_spec.js b/spec/javascripts/app/collections/likes_collections_spec.js index 292888403..b23f5ae7a 100644 --- a/spec/javascripts/app/collections/likes_collections_spec.js +++ b/spec/javascripts/app/collections/likes_collections_spec.js @@ -1,10 +1,9 @@ describe("app.collections.Likes", function(){ describe("url", function(){ it("should user the post id", function(){ - var post =new app.models.Post({id : 5}) - var collection = new app.collections.Likes([], {post : post}) - expect(collection.url).toBe("/posts/5/likes") - }) - }) -}) - + var post =new app.models.Post({id : 5}); + var collection = new app.collections.Likes([], {post : post}); + expect(collection.url).toBe("/posts/5/likes"); + }); + }); +}); diff --git a/spec/javascripts/app/collections/tag_following_collection_spec.js b/spec/javascripts/app/collections/tag_following_collection_spec.js index b3b4c646c..d776d35e6 100644 --- a/spec/javascripts/app/collections/tag_following_collection_spec.js +++ b/spec/javascripts/app/collections/tag_following_collection_spec.js @@ -1,21 +1,21 @@ describe("app.collections.TagFollowings", function(){ beforeEach(function(){ this.collection = new app.collections.TagFollowings(); - }) + }); describe("comparator", function() { it("should compare in reverse order", function() { var a = new app.models.TagFollowing({name: "aaa"}), - b = new app.models.TagFollowing({name: "zzz"}) - expect(this.collection.comparator(a, b)).toBeGreaterThan(0) - }) - }) + b = new app.models.TagFollowing({name: "zzz"}); + expect(this.collection.comparator(a, b)).toBeGreaterThan(0); + }); + }); describe("create", function(){ it("should not allow duplicates", function(){ - this.collection.create({"name":"name"}) - this.collection.create({"name":"name"}) - expect(this.collection.length).toBe(1) - }) - }) -}) + this.collection.create({"name":"name"}); + this.collection.create({"name":"name"}); + expect(this.collection.length).toBe(1); + }); + }); +}); diff --git a/spec/javascripts/app/helpers/date_formatter_spec.js b/spec/javascripts/app/helpers/date_formatter_spec.js index 9d317a108..141cdbd6e 100644 --- a/spec/javascripts/app/helpers/date_formatter_spec.js +++ b/spec/javascripts/app/helpers/date_formatter_spec.js @@ -3,31 +3,30 @@ describe("app.helpers.dateFormatter", function(){ beforeEach(function(){ this.statusMessage = factory.post(); this.formatter = app.helpers.dateFormatter; - }) + }); describe("parse", function(){ context("modern web browsers", function(){ it ("supports ISO 8601 UTC dates", function(){ var timestamp = new Date(this.statusMessage.get("created_at")).getTime(); expect(this.formatter.parse(this.statusMessage.get("created_at"))).toEqual(timestamp); - }) - }) + }); + }); context("legacy web browsers", function(){ it("supports ISO 8601 UTC dates", function(){ var timestamp = new Date(this.statusMessage.get("created_at")).getTime(); expect(this.formatter.parseISO8601UTC(this.statusMessage.get("created_at"))).toEqual(timestamp); - }) - }) + }); + }); context("status messages", function(){ it("uses ISO 8601 UTC dates", function(){ var iso8601_utc_pattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(.(\d{3}))?Z$/; expect(iso8601_utc_pattern.test(this.statusMessage.get("created_at"))).toBe(true); - }) - }) - }) - -}) + }); + }); + }); +}); diff --git a/spec/javascripts/app/helpers/text_formatter_spec.js b/spec/javascripts/app/helpers/text_formatter_spec.js index 0e01004bf..b00ee3155 100644 --- a/spec/javascripts/app/helpers/text_formatter_spec.js +++ b/spec/javascripts/app/helpers/text_formatter_spec.js @@ -3,7 +3,7 @@ describe("app.helpers.textFormatter", function(){ beforeEach(function(){ this.statusMessage = factory.post(); this.formatter = app.helpers.textFormatter; - }) + }); // Some basic specs. For more detailed specs see // https://github.com/svbergerem/markdown-it-hashtag/tree/master/test @@ -34,25 +34,25 @@ describe("app.helpers.textFormatter", function(){ name : "Alice Smith", diaspora_id : "alice@example.com", id : "555" - }) + }); this.bob = factory.author({ name : "Bob Grimm", diaspora_id : "bob@example.com", id : "666" - }) + }); - this.statusMessage.set({text: "hey there @{Alice Smith; alice@example.com} and @{Bob Grimm; bob@example.com}"}) - this.statusMessage.set({mentioned_people : [this.alice, this.bob]}) - }) + this.statusMessage.set({text: "hey there @{Alice Smith; alice@example.com} and @{Bob Grimm; bob@example.com}"}); + this.statusMessage.set({mentioned_people : [this.alice, this.bob]}); + }); it("matches mentions", function(){ - var formattedText = this.formatter(this.statusMessage.get("text"), this.statusMessage.get("mentioned_people")) + var formattedText = this.formatter(this.statusMessage.get("text"), this.statusMessage.get("mentioned_people")); var wrapper = $("
").html(formattedText); _.each([this.alice, this.bob], function(person) { - expect(wrapper.find("a[href='/people/" + person.guid + "']").text()).toContain(person.name) - }) + expect(wrapper.find("a[href='/people/" + person.guid + "']").text()).toContain(person.name); + }); }); it("returns mentions for on posts that haven't been saved yet (framer posts)", function(){ @@ -61,18 +61,18 @@ describe("app.helpers.textFormatter", function(){ handle : "bob@example.com", url : 'googlebot.com', id : "666" - }) + }); - this.statusMessage.set({'mentioned_people' : [freshBob] }) + this.statusMessage.set({'mentioned_people' : [freshBob] }); - var formattedText = this.formatter(this.statusMessage.get("text"), this.statusMessage.get("mentioned_people")) + var formattedText = this.formatter(this.statusMessage.get("text"), this.statusMessage.get("mentioned_people")); var wrapper = $("
").html(formattedText); - expect(wrapper.find("a[href='googlebot.com']").text()).toContain(freshBob.name) - }) + expect(wrapper.find("a[href='googlebot.com']").text()).toContain(freshBob.name); + }); it('returns the name of the mention if the mention does not exist in the array', function(){ - var text = "hey there @{Chris Smith; chris@example.com}" - var formattedText = this.formatter(text, []) + var text = "hey there @{Chris Smith; chris@example.com}"; + var formattedText = this.formatter(text, []); expect(formattedText.match(/ Pins", one : "<%= count %> Pin"} } - }) + }); var posts = $.parseJSON(spec.readFixture("stream_json")); this.post = new app.models.Post(posts[0]); // post with a like @@ -18,39 +18,38 @@ describe("app.views.LikesInfo", function(){ it("displays a the like count if it is above zero", function() { spyOn(this.view.model.interactions, "likesCount").and.returnValue(3); this.view.render(); - expect($(this.view.el).find(".expand_likes").length).toBe(1) - }) + expect($(this.view.el).find(".expand_likes").length).toBe(1); + }); it("does not display the like count if it is zero", function() { spyOn(this.view.model.interactions, "likesCount").and.returnValue(0); this.view.render(); expect($(this.view.el).html().trim()).toBe(""); - }) + }); it("fires on a model change", function(){ - spyOn(this.view, "postRenderTemplate") - this.view.model.interactions.trigger('change') - expect(this.view.postRenderTemplate).toHaveBeenCalled() - }) - }) + spyOn(this.view, "postRenderTemplate"); + this.view.model.interactions.trigger('change'); + expect(this.view.postRenderTemplate).toHaveBeenCalled(); + }); + }); describe("showAvatars", function(){ beforeEach(function(){ - spyOn(this.post.interactions, "fetch").and.callThrough() - }) + spyOn(this.post.interactions, "fetch").and.callThrough(); + }); it("calls fetch on the model's like collection", function(){ this.view.showAvatars(); expect(this.post.interactions.fetch).toHaveBeenCalled(); - }) + }); it("sets the fetched response to the model's likes", function(){ //placeholder... not sure how to test done functionalty here - }) + }); it("re-renders the view", function(){ //placeholder... not sure how to test done functionalty here - }) - }) -}) - + }); + }); +}); diff --git a/spec/javascripts/app/views/location_view_spec.js b/spec/javascripts/app/views/location_view_spec.js index 68e5ac59b..42e04741c 100644 --- a/spec/javascripts/app/views/location_view_spec.js +++ b/spec/javascripts/app/views/location_view_spec.js @@ -12,6 +12,6 @@ describe("app.views.Location", function(){ expect($("#location_address")).toBeTruthy(); expect($("#location_coords")).toBeTruthy(); expect($("#hide_location")).toBeTruthy(); - }) + }); }); }); diff --git a/spec/javascripts/app/views/oembed_view_spec.js b/spec/javascripts/app/views/oembed_view_spec.js index 7af824d20..f46f8c91c 100644 --- a/spec/javascripts/app/views/oembed_view_spec.js +++ b/spec/javascripts/app/views/oembed_view_spec.js @@ -9,7 +9,7 @@ describe("app.views.OEmbed", function(){ } }); - this.view = new app.views.OEmbed({model : this.statusMessage}) + this.view = new app.views.OEmbed({model : this.statusMessage}); }); describe("rendering", function(){ @@ -27,7 +27,7 @@ describe("app.views.OEmbed", function(){ it("should set types.video on the data", function() { this.view.render(); - expect(this.view.model.get("o_embed_cache").data.types.video).toBe(true) + expect(this.view.model.get("o_embed_cache").data.types.video).toBe(true); }); it("shows the thumb with overlay", function(){ @@ -53,20 +53,20 @@ describe("app.views.OEmbed", function(){ }); it("provides oembed html from the model response", function(){ - this.view.render() - expect(this.view.$el.html()).toContain("some html") + this.view.render(); + expect(this.view.$el.html()).toContain("some html"); }); }); }); describe("presenter", function(){ it("provides oembed html from the model", function(){ - expect(this.view.presenter().o_embed_html).toContain("some html") + expect(this.view.presenter().o_embed_html).toContain("some html"); }); it("does not provide oembed html from the model response if none is present", function(){ - this.statusMessage.set({"o_embed_cache" : null}) + this.statusMessage.set({"o_embed_cache" : null}); expect(this.view.presenter().o_embed_html).toBe(""); }); }); -}); \ No newline at end of file +}); diff --git a/spec/javascripts/app/views/open_graph_view_spec.js b/spec/javascripts/app/views/open_graph_view_spec.js index d17c345ba..77bba41a1 100644 --- a/spec/javascripts/app/views/open_graph_view_spec.js +++ b/spec/javascripts/app/views/open_graph_view_spec.js @@ -12,7 +12,7 @@ describe("app.views.OpenGraph", function() { "open_graph_cache": open_graph_cache }); - this.view = new app.views.OpenGraph({model : this.statusMessage}) + this.view = new app.views.OpenGraph({model : this.statusMessage}); }); describe("rendering", function(){ diff --git a/spec/javascripts/app/views/photo_viewer_spec.js b/spec/javascripts/app/views/photo_viewer_spec.js index 6f25d580b..645f50d21 100644 --- a/spec/javascripts/app/views/photo_viewer_spec.js +++ b/spec/javascripts/app/views/photo_viewer_spec.js @@ -5,15 +5,15 @@ describe("app.views.PhotoViewer", function(){ factory.photoAttrs({sizes : {large : "http://tieguy.org/me.jpg"}}), factory.photoAttrs({sizes : {large : "http://whatthefuckiselizabethstarkupto.com/none_knows.gif"}}) //SIC ] - }) - this.view = new app.views.PhotoViewer({model : this.model}) - }) + }); + this.view = new app.views.PhotoViewer({model : this.model}); + }); describe("rendering", function(){ it("should have an image for each photoAttr on the model", function(){ - this.view.render() - expect(this.view.$("img").length).toBe(2) - expect(this.view.$("img[src='http://tieguy.org/me.jpg']")).toExist() - }) - }) -}) \ No newline at end of file + this.view.render(); + expect(this.view.$("img").length).toBe(2); + expect(this.view.$("img[src='http://tieguy.org/me.jpg']")).toExist(); + }); + }); +}); diff --git a/spec/javascripts/app/views/poll_view_spec.js b/spec/javascripts/app/views/poll_view_spec.js index 04124467c..8f86d6eb3 100644 --- a/spec/javascripts/app/views/poll_view_spec.js +++ b/spec/javascripts/app/views/poll_view_spec.js @@ -10,7 +10,7 @@ describe("app.views.Poll", function(){ var percentage = (this.view.poll.poll_answers[0].vote_count / this.view.poll.participation_count)*100; expect(this.view.$('.poll_progress_bar:first').css('width')).toBe(percentage+"%"); expect(this.view.$(".percentage:first").text()).toBe(percentage + "%"); - }) + }); }); describe("toggleResult", function(){ @@ -18,7 +18,7 @@ describe("app.views.Poll", function(){ expect(this.view.$('.poll_progress_bar_wrapper:first').css('display')).toBe("none"); this.view.toggleResult(null); expect(this.view.$('.poll_progress_bar_wrapper:first').css('display')).toBe("block"); - }) + }); }); describe("vote", function(){ @@ -32,7 +32,7 @@ describe("app.views.Poll", function(){ var obj = JSON.parse(jasmine.Ajax.requests.mostRecent().params); expect(obj.poll_id).toBe(poll.poll_id); expect(obj.poll_answer_id).toBe(answer.id); - }) + }); }); describe("render", function() { diff --git a/spec/javascripts/app/views/publisher_view_spec.js b/spec/javascripts/app/views/publisher_view_spec.js index eb3d35a55..ca38368bc 100644 --- a/spec/javascripts/app/views/publisher_view_spec.js +++ b/spec/javascripts/app/views/publisher_view_spec.js @@ -55,7 +55,7 @@ describe("app.views.Publisher", function() { it("removes the 'active' class from the publisher element", function(){ this.view.close($.Event()); expect($(this.view.el)).toHaveClass("closed"); - }) + }); it("resets the element's height", function() { $(this.view.el).find("#status_message_fake_text").height(100); @@ -70,14 +70,14 @@ describe("app.views.Publisher", function() { this.view.clear($.Event()); expect(this.view.close).toHaveBeenCalled(); - }) + }); it("calls removePostPreview", function(){ spyOn(this.view, "removePostPreview"); this.view.clear($.Event()); expect(this.view.removePostPreview).toHaveBeenCalled(); - }) + }); it("clears all textareas", function(){ _.each(this.view.$("textarea"), function(element){ @@ -90,27 +90,27 @@ describe("app.views.Publisher", function() { _.each(this.view.$("textarea"), function(element){ expect($(element).val()).toBe(""); }); - }) + }); it("removes all photos from the dropzone area", function(){ var self = this; _.times(3, function(){ - self.view.el_photozone.append($("
  • ")) + self.view.el_photozone.append($("
  • ")); }); expect(this.view.el_photozone.html()).not.toBe(""); this.view.clear($.Event()); expect(this.view.el_photozone.html()).toBe(""); - }) + }); it("removes all photo values appended by the photo uploader", function(){ - $(this.view.el).prepend("") + $(this.view.el).prepend(""); var photoValuesInput = this.view.$("input[name='photos[]']"); - photoValuesInput.val("3") + photoValuesInput.val("3"); this.view.clear($.Event()); expect(this.view.$("input[name='photos[]']").length).toBe(0); - }) + }); it("destroy location if exists", function(){ setFixtures('
    '); @@ -119,7 +119,7 @@ describe("app.views.Publisher", function() { expect($("#location").length).toBe(1); this.view.clear($.Event()); expect($("#location").length).toBe(0); - }) + }); }); describe("createStatusMessage", function(){ @@ -127,7 +127,7 @@ describe("app.views.Publisher", function() { spyOn(this.view, "handleTextchange"); this.view.createStatusMessage($.Event()); expect(this.view.handleTextchange).toHaveBeenCalled(); - }) + }); }); describe('#setText', function() { @@ -165,7 +165,7 @@ describe("app.views.Publisher", function() { describe("publishing a post with keyboard", function(){ it("should submit the form when ctrl+enter is pressed", function(){ this.view.render(); - var form = this.view.$("form") + var form = this.view.$("form"); var submitCallback = jasmine.createSpy().and.returnValue(false); form.submit(submitCallback); @@ -175,7 +175,7 @@ describe("app.views.Publisher", function() { expect(submitCallback).toHaveBeenCalled(); expect($(this.view.el)).not.toHaveClass("closed"); - }) + }); }); describe("_beforeUnload", function(){ @@ -202,7 +202,7 @@ describe("app.views.Publisher", function() { expect(this.view._beforeUnload(e)).toBe(undefined); expect(e.returnValue).toBe(undefined); }); - }) + }); }); context("services", function(){ @@ -401,7 +401,7 @@ describe("app.views.Publisher", function() { // validates there is one location created expect($("#location").length).toBe(1); - }) + }); }); describe('#destroyLocation', function(){ @@ -411,7 +411,7 @@ describe("app.views.Publisher", function() { this.view.destroyLocation(); expect($("#location").length).toBe(0); - }) + }); }); describe('#avoidEnter', function(){ @@ -422,7 +422,7 @@ describe("app.views.Publisher", function() { // should return false in order to avoid the form submition expect(this.view.avoidEnter(evt)).toBeFalsy(); - }) + }); }); }); @@ -503,7 +503,7 @@ describe("app.views.Publisher", function() { it('shows it in text form', function() { var info = this.view.view_uploader.el_info; - expect(info.text()).toBe(Diaspora.I18n.t('photo_uploader.completed', {file: 'test.jpg'})) + expect(info.text()).toBe(Diaspora.I18n.t('photo_uploader.completed', {file: 'test.jpg'})); }); it('adds a hidden input to the publisher', function() { @@ -541,7 +541,7 @@ describe("app.views.Publisher", function() { it('shows error message', function() { var info = this.view.view_uploader.el_info; - expect(info.text()).toBe(Diaspora.I18n.t('photo_uploader.error', {file: 'test.jpg'})) + expect(info.text()).toBe(Diaspora.I18n.t('photo_uploader.error', {file: 'test.jpg'})); }); }); }); diff --git a/spec/javascripts/app/views/stream_faces_view_spec.js b/spec/javascripts/app/views/stream_faces_view_spec.js index 259dcd074..98d24897a 100644 --- a/spec/javascripts/app/views/stream_faces_view_spec.js +++ b/spec/javascripts/app/views/stream_faces_view_spec.js @@ -1,50 +1,50 @@ describe("app.views.StreamFaces", function(){ beforeEach(function(){ - var rebeccaBlack = factory.author({name : "Rebecca Black", id : 1492}) - this.post1 = factory.post({author : rebeccaBlack}) - this.post2 = factory.post({author : factory.author({name : "John Stamos", id : 1987})}) - this.post3 = factory.post({author : factory.author({name : "Michelle Tanner", id : 1986})}) - this.post4 = factory.post({author : factory.author({name : "Barack Obama", id : 2000})}) - this.post5 = factory.post({author : factory.author({name : "Obi-wan Kenobi", id : 2020})}) - this.post6 = factory.post({author : rebeccaBlack}) - this.post7 = factory.post({author : rebeccaBlack}) + var rebeccaBlack = factory.author({name : "Rebecca Black", id : 1492}); + this.post1 = factory.post({author : rebeccaBlack}); + this.post2 = factory.post({author : factory.author({name : "John Stamos", id : 1987})}); + this.post3 = factory.post({author : factory.author({name : "Michelle Tanner", id : 1986})}); + this.post4 = factory.post({author : factory.author({name : "Barack Obama", id : 2000})}); + this.post5 = factory.post({author : factory.author({name : "Obi-wan Kenobi", id : 2020})}); + this.post6 = factory.post({author : rebeccaBlack}); + this.post7 = factory.post({author : rebeccaBlack}); - app.stream = new app.models.Stream() + app.stream = new app.models.Stream(); app.stream.add([this.post1, this.post2, this.post3, this.post4, this.post5, this.post6, this.post7]); - this.posts = app.stream.items + this.posts = app.stream.items; - this.view = new app.views.StreamFaces({collection : this.posts}) - }) + this.view = new app.views.StreamFaces({collection : this.posts}); + }); it("should take them unique", function(){ - this.view.render() - expect(this.view.people.length).toBe(5) - }) + this.view.render(); + expect(this.view.people.length).toBe(5); + }); it("findsPeople when the collection changes", function(){ - this.posts.add(factory.post({author : factory.author({name : "Harriet Tubman"})})) - expect(this.view.people.length).toBe(6) - }) + this.posts.add(factory.post({author : factory.author({name : "Harriet Tubman"})})); + expect(this.view.people.length).toBe(6); + }); describe(".render", function(){ beforeEach(function(){ - this.view.render() - }) + this.view.render(); + }); it("appends the people's avatars", function(){ - expect(this.view.$("img").length).toBe(5) - }) + expect(this.view.$("img").length).toBe(5); + }); it("links to the people", function(){ - expect(this.view.$("a").length).toBe(5) - }) + expect(this.view.$("a").length).toBe(5); + }); it("rerenders when people are added, but caps to 15 people", function(){ - var posts = _.map(_.range(20), function(){ return factory.post()}) - this.posts.reset(posts) //add 20 posts silently to the collection - this.posts.add(factory.post()) //trigger an update - expect(this.view.$("img").length).toBe(15) - }) - }) -}) + var posts = _.map(_.range(20), function(){ return factory.post()}); + this.posts.reset(posts); //add 20 posts silently to the collection + this.posts.add(factory.post()); //trigger an update + expect(this.view.$("img").length).toBe(15); + }); + }); +}); diff --git a/spec/javascripts/app/views/stream_post_spec.js b/spec/javascripts/app/views/stream_post_spec.js index 307ac8156..e26618492 100644 --- a/spec/javascripts/app/views/stream_post_spec.js +++ b/spec/javascripts/app/views/stream_post_spec.js @@ -1,12 +1,12 @@ describe("app.views.StreamPost", function(){ beforeEach(function(){ - this.PostViewClass = app.views.StreamPost + this.PostViewClass = app.views.StreamPost; var posts = $.parseJSON(spec.readFixture("stream_json")); this.collection = new app.collections.Posts(posts); this.statusMessage = this.collection.models[0]; this.reshare = this.collection.models[1]; - }) + }); describe("events", function(){ var _PostViewClass, @@ -63,8 +63,8 @@ describe("app.views.StreamPost", function(){ one : "<%= count %> Like", other : "<%= count %> Likes" } - }}) - }) + }}); + }); context("reshare", function(){ it("displays a reshare count", function(){ @@ -84,34 +84,34 @@ describe("app.views.StreamPost", function(){ context("likes", function(){ it("displays a like count", function(){ - this.statusMessage.interactions.set({likes_count : 1}) + this.statusMessage.interactions.set({likes_count : 1}); var view = new this.PostViewClass({model : this.statusMessage}).render(); - expect($(view.el).html()).toContain(Diaspora.I18n.t('stream.likes', {count: 1})) - }) + expect($(view.el).html()).toContain(Diaspora.I18n.t('stream.likes', {count: 1})); + }); it("does not display a like count for 'zero'", function(){ - this.statusMessage.interactions.set({likes_count : 0}) + this.statusMessage.interactions.set({likes_count : 0}); var view = new this.PostViewClass({model : this.statusMessage}).render(); - expect($(view.el).html()).not.toContain("0 Likes") - }) - }) + expect($(view.el).html()).not.toContain("0 Likes"); + }); + }); context("embed_html", function(){ it("provides oembed html from the model response", function(){ - this.statusMessage.set({"o_embed_cache" : o_embed_cache}) + this.statusMessage.set({"o_embed_cache" : o_embed_cache}); var view = new app.views.StreamPost({model : this.statusMessage}).render(); - expect(view.$el.html()).toContain(o_embed_cache.data.html) - }) - }) + expect(view.$el.html()).toContain(o_embed_cache.data.html); + }); + }); context("og_html", function(){ it("provides opengraph preview based on the model reponse", function(){ this.statusMessage.set({"open_graph_cache" : open_graph_cache}); var view = new app.views.StreamPost({model : this.statusMessage}).render(); - expect(view.$el.html()).toContain(open_graph_cache.title) + expect(view.$el.html()).toContain(open_graph_cache.title); }); it("does not provide opengraph preview, when oembed is available", function(){ this.statusMessage.set({ @@ -120,23 +120,23 @@ describe("app.views.StreamPost", function(){ }); var view = new app.views.StreamPost({model : this.statusMessage}).render(); - expect(view.$el.html()).not.toContain(open_graph_cache.title) - }) + expect(view.$el.html()).not.toContain(open_graph_cache.title); + }); it("truncates long opengraph descriptions in stream view to be 250 chars or less", function() { this.statusMessage.set({"open_graph_cache" : open_graph_cache_extralong}); var view = new app.views.StreamPost({model : this.statusMessage}).render(); expect(view.$el.find('.og-description').html().length).toBeLessThan(251); }); - }) + }); context("user not signed in", function(){ it("does not provide a Feedback view", function(){ - logout() + logout(); var view = new this.PostViewClass({model : this.statusMessage}).render(); expect(view.feedbackView()).toBeFalsy(); - }) - }) + }); + }); context("NSFW", function(){ beforeEach(function(){ @@ -144,19 +144,19 @@ describe("app.views.StreamPost", function(){ this.view = new this.PostViewClass({model : this.statusMessage}).render(); this.hiddenPosts = function(){ - return this.view.$(".nsfw-shield") - } + return this.view.$(".nsfw-shield"); + }; }); it("contains a shield element", function(){ - expect(this.hiddenPosts().length).toBe(1) + expect(this.hiddenPosts().length).toBe(1); }); it("does not contain a shield element when nsfw is false", function(){ this.statusMessage.set({nsfw: false}); this.view.render(); expect(this.hiddenPosts()).not.toExist(); - }) + }); context("showing a single post", function(){ it("removes the shields when the post is clicked", function(){ @@ -168,12 +168,12 @@ describe("app.views.StreamPost", function(){ context("clicking the toggle nsfw link toggles it on the user", function(){ it("calls toggleNsfw on the user", function(){ - spyOn(app.user(), "toggleNsfwState") + spyOn(app.user(), "toggleNsfwState"); this.view.$(".toggle_nsfw_state").first().click(); expect(app.user().toggleNsfwState).toHaveBeenCalled(); }); - }) - }) + }); + }); context("user views their own post", function(){ beforeEach(function(){ @@ -181,11 +181,11 @@ describe("app.views.StreamPost", function(){ id : app.user().id }}); this.view = new this.PostViewClass({model : this.statusMessage}).render(); - }) + }); it("contains remove post", function(){ expect(this.view.$(".remove_post")).toExist(); - }) + }); it("destroys the view when they delete a their post from the show page", function(){ spyOn(window, "confirm").and.returnValue(true); @@ -194,8 +194,8 @@ describe("app.views.StreamPost", function(){ expect(window.confirm).toHaveBeenCalled(); expect(this.view.el).not.toBeInDOM(); - }) - }) + }); + }); - }) + }); }); diff --git a/spec/javascripts/app/views/stream_view_spec.js b/spec/javascripts/app/views/stream_view_spec.js index 3935d13a2..412728222 100644 --- a/spec/javascripts/app/views/stream_view_spec.js +++ b/spec/javascripts/app/views/stream_view_spec.js @@ -55,7 +55,7 @@ describe("app.views.Stream", function() { }); it("fetches moar when the user is at the bottom of the page", function() { - expect(this.view.model.fetch).toHaveBeenCalled() + expect(this.view.model.fetch).toHaveBeenCalled(); }); }); diff --git a/spec/javascripts/app/views/tag_following_action_view_spec.js b/spec/javascripts/app/views/tag_following_action_view_spec.js index 29f8b275c..8639ee5fa 100644 --- a/spec/javascripts/app/views/tag_following_action_view_spec.js +++ b/spec/javascripts/app/views/tag_following_action_view_spec.js @@ -2,22 +2,22 @@ describe("app.views.TagFollowingAction", function(){ beforeEach(function(){ app.tagFollowings = new app.collections.TagFollowings(); this.tagName = "test_tag"; - this.view = new app.views.TagFollowingAction({tagName : this.tagName}) - }) + this.view = new app.views.TagFollowingAction({tagName : this.tagName}); + }); describe("render", function(){ it("shows the output of followString", function(){ - spyOn(this.view, "tag_is_followed").and.returnValue(false) - spyOn(this.view, "followString").and.returnValue("a_follow_string") - expect(this.view.render().$('input').val()).toMatch(/^a_follow_string$/) - }) + spyOn(this.view, "tag_is_followed").and.returnValue(false); + spyOn(this.view, "followString").and.returnValue("a_follow_string"); + expect(this.view.render().$('input').val()).toMatch(/^a_follow_string$/); + }); it("should have the extra classes if the tag is followed", function(){ - spyOn(this.view, "tag_is_followed").and.returnValue(true) - expect(this.view.render().$('input').hasClass("followed")).toBe(true) - expect(this.view.render().$('input').hasClass("green")).toBe(true) - }) - }) + spyOn(this.view, "tag_is_followed").and.returnValue(true); + expect(this.view.render().$('input').hasClass("followed")).toBe(true); + expect(this.view.render().$('input').hasClass("green")).toBe(true); + }); + }); describe("tagAction", function(){ it("toggles the tagFollowed from followed to unfollowed", function(){ @@ -29,22 +29,22 @@ describe("app.views.TagFollowingAction", function(){ spyOn(this.view.model, "destroy").and.callFake(_.bind(function(){ // model.destroy leads to collection.remove, which is bound to getTagFollowing this.view.getTagFollowing(); - }, this) ) + }, this) ); this.view.tagAction(); - expect(origModel.destroy).toHaveBeenCalled() + expect(origModel.destroy).toHaveBeenCalled(); expect(this.view.tag_is_followed()).toBe(false); - }) + }); it("toggles the tagFollowed from unfollowed to followed", function(){ expect(this.view.tag_is_followed()).toBe(false); spyOn(app.tagFollowings, "create").and.callFake(function(model){ // 'save' the model by giving it an id - model.set("id", 3) - }) + model.set("id", 3); + }); this.view.tagAction(); expect(this.view.tag_is_followed()).toBe(true); - }) - }) -}) + }); + }); +}); diff --git a/spec/javascripts/app/views_spec.js b/spec/javascripts/app/views_spec.js index cf54c6eb0..ec8861577 100644 --- a/spec/javascripts/app/views_spec.js +++ b/spec/javascripts/app/views_spec.js @@ -1,22 +1,22 @@ describe("app.views.Base", function(){ describe("#render", function(){ beforeEach(function(){ - var staticTemplateClass = app.views.Base.extend({ templateName : "static-text" }) + var staticTemplateClass = app.views.Base.extend({ templateName : "static-text" }); - this.model = new Backbone.Model({text : "model attributes are in the default presenter"}) - this.view = new staticTemplateClass({model: this.model}) - this.view.render() - }) + this.model = new Backbone.Model({text : "model attributes are in the default presenter"}); + this.view = new staticTemplateClass({model: this.model}); + this.view.render(); + }); it("renders the template with the presenter", function(){ - expect($(this.view.el).text().trim()).toBe("model attributes are in the default presenter") - }) + expect($(this.view.el).text().trim()).toBe("model attributes are in the default presenter"); + }); it("it evaluates the presenter every render", function(){ - this.model.set({text : "OMG It's a party" }) - this.view.render() - expect($(this.view.el).text().trim()).toBe("OMG It's a party") - }) + this.model.set({text : "OMG It's a party" }); + this.view.render(); + expect($(this.view.el).text().trim()).toBe("OMG It's a party"); + }); context("subViewRendering", function(){ beforeEach(function(){ @@ -28,7 +28,7 @@ describe("app.views.Base", function(){ }, initialize : function(){ - this.subview1 = stubView("OMG First Subview") + this.subview1 = stubView("OMG First Subview"); }, presenter: { @@ -36,47 +36,47 @@ describe("app.views.Base", function(){ }, postRenderTemplate : function(){ - $(this.el).append("
    ") - $(this.el).append("
    ") + $(this.el).append("
    "); + $(this.el).append("
    "); }, createSubview2 : function(){ - return stubView("furreal this is the Second Subview") + return stubView("furreal this is the Second Subview"); } - }) + }); - this.view = new viewClass().render() - }) + this.view = new viewClass().render(); + }); it("repsects the respects the template rendered with the presenter", function(){ - expect(this.view.$('.text').text().trim()).toBe("this comes through on the original render") - }) + expect(this.view.$('.text').text().trim()).toBe("this comes through on the original render"); + }); it("renders subviews from views that are properties of the object", function(){ - expect(this.view.$('.subview1').text().trim()).toBe("OMG First Subview") - }) + expect(this.view.$('.subview1').text().trim()).toBe("OMG First Subview"); + }); it("renders the sub views from functions", function(){ - expect(this.view.$('.subview2').text().trim()).toBe("furreal this is the Second Subview") - }) - }) + expect(this.view.$('.subview2').text().trim()).toBe("furreal this is the Second Subview"); + }); + }); context("calling out to third party plugins", function(){ it("replaces .time with relative time ago in words", function(){ - spyOn($.fn, "timeago") - this.view.render() - expect($.fn.timeago).toHaveBeenCalled() - expect($.fn.timeago.calls.mostRecent().object.selector).toBe("time") - }) + spyOn($.fn, "timeago"); + this.view.render(); + expect($.fn.timeago).toHaveBeenCalled(); + expect($.fn.timeago.calls.mostRecent().object.selector).toBe("time"); + }); it("initializes tooltips declared with the view's tooltipSelector property", function(){ - this.view.tooltipSelector = ".christopher_columbus, .barrack_obama, .block_user" + this.view.tooltipSelector = ".christopher_columbus, .barrack_obama, .block_user"; - spyOn($.fn, "tooltip") - this.view.render() - expect($.fn.tooltip.calls.mostRecent().object.selector).toBe(".christopher_columbus, .barrack_obama, .block_user") - }) - }) - }) -}) + spyOn($.fn, "tooltip"); + this.view.render(); + expect($.fn.tooltip.calls.mostRecent().object.selector).toBe(".christopher_columbus, .barrack_obama, .block_user"); + }); + }); + }); +}); diff --git a/spec/javascripts/diaspora-spec.js b/spec/javascripts/diaspora-spec.js index 9c85666e5..3376c1e45 100644 --- a/spec/javascripts/diaspora-spec.js +++ b/spec/javascripts/diaspora-spec.js @@ -57,7 +57,7 @@ describe("Diaspora", function() { describe("subscribe", function() { it("will subscribe to multiple events", function() { var firstEventCalled = false, - secondEventCalled = false + secondEventCalled = false; events = Diaspora.EventBroker.extend({}); events.subscribe("first/event second/event", function() { @@ -78,7 +78,7 @@ describe("Diaspora", function() { describe("publish", function() { it("will publish multiple events", function() { var firstEventCalled = false, - secondEventCalled = false + secondEventCalled = false; events = Diaspora.EventBroker.extend({}); events.subscribe("first/event second/event", function() { diff --git a/spec/javascripts/helpers/SpecHelper.js b/spec/javascripts/helpers/SpecHelper.js index 5c80a2246..14bf5d491 100644 --- a/spec/javascripts/helpers/SpecHelper.js +++ b/spec/javascripts/helpers/SpecHelper.js @@ -69,7 +69,7 @@ afterEach(function() { jasmine.clock().uninstall(); jasmine.Ajax.uninstall(); - $("#jasmine_content").empty() + $("#jasmine_content").empty(); expect(spec.loadFixtureCount).toBeLessThan(2); spec.loadFixtureCount = 0; }); @@ -79,21 +79,21 @@ window.stubView = function stubView(text){ var stubClass = Backbone.View.extend({ render : function(){ $(this.el).html(text); - return this + return this; } - }) + }); return new stubClass(); -} +}; window.loginAs = function loginAs(attrs){ - return app.currentUser = app.user(factory.userAttrs(attrs)) -} + return app.currentUser = app.user(factory.userAttrs(attrs)); +}; window.logout = function logout(){ - this.app._user = undefined - return app.currentUser = new app.models.User() -} + this.app._user = undefined; + return app.currentUser = new app.models.User(); +}; window.hipsterIpsumFourParagraphs = "Mcsweeney's mumblecore irony fugiat, ex iphone brunch helvetica eiusmod retro" + " sustainable mlkshk. Pop-up gentrify velit readymade ad exercitation 3 wolf moon. Vinyl aute laboris artisan irony, " + @@ -120,7 +120,7 @@ window.hipsterIpsumFourParagraphs = "Mcsweeney's mumblecore irony fugiat, ex iph "mlkshk assumenda. Typewriter terry richardson pork belly, cupidatat tempor craft beer tofu sunt qui gentrify eiusmod " + "id. Letterpress pitchfork wayfarers, eu sunt lomo helvetica pickled dreamcatcher bicycle rights. Aliqua banksy " + "cliche, sapiente anim chambray williamsburg vinyl cardigan. Pork belly mcsweeney's anim aliqua. DIY vice portland " + - "thundercats est vegan etsy, gastropub helvetica aliqua. Artisan jean shorts american apparel duis esse trust fund." + "thundercats est vegan etsy, gastropub helvetica aliqua. Artisan jean shorts american apparel duis esse trust fund."; spec.clearLiveEventBindings = function() { var events = jQuery.data(document, "events"); diff --git a/spec/javascripts/helpers/factory.js b/spec/javascripts/helpers/factory.js index 34e96045b..e52cb683c 100644 --- a/spec/javascripts/helpers/factory.js +++ b/spec/javascripts/helpers/factory.js @@ -2,12 +2,12 @@ factory = { id : { current : 0, next : function(){ - return factory.id.current += 1 + return factory.id.current += 1; } }, guid : function(){ - return 'omGUID' + this.id.next() + return 'omGUID' + this.id.next(); }, like : function(overrides){ @@ -16,9 +16,9 @@ factory = { "author" : this.author(), "guid" : this.guid(), "id" : this.id.next() - } + }; - return _.extend(defaultAttrs, overrides) + return _.extend(defaultAttrs, overrides); }, comment : function(overrides) { @@ -28,17 +28,17 @@ factory = { "guid" : this.guid(), "id" : this.id.next(), "text" : "This is a comment!" - } + }; - return new app.models.Comment(_.extend(defaultAttrs, overrides)) + return new app.models.Comment(_.extend(defaultAttrs, overrides)); }, user : function(overrides) { - return new app.models.User(factory.userAttrs(overrides)) + return new app.models.User(factory.userAttrs(overrides)); }, userAttrs : function(overrides){ - var id = this.id.next() + var id = this.id.next(); var defaultAttrs = { "name":"Awesome User" + id, "id": id, @@ -47,9 +47,9 @@ factory = { "large":"http://localhost:3000/images/user/uma.jpg", "medium":"http://localhost:3000/images/user/uma.jpg", "small":"http://localhost:3000/images/user/uma.jpg"} - } + }; - return _.extend(defaultAttrs, overrides) + return _.extend(defaultAttrs, overrides); }, postAttrs : function(){ @@ -76,7 +76,7 @@ factory = { "likes" : [], "reshares" : [] } - } + }; }, profileAttrs: function(overrides) { @@ -145,12 +145,12 @@ factory = { medium: "http://localhost:3000/uploads/images/thumb_medium_d85410bd19db1016894c.jpg", small: "http://localhost:3000/uploads/images/thumb_small_d85410bd19db1016894c.jpg" } - }, overrides) + }, overrides); }, post : function(overrides) { - defaultAttrs = _.extend(factory.postAttrs(), {"author" : this.author()}) - return new app.models.Post(_.extend(defaultAttrs, overrides)) + defaultAttrs = _.extend(factory.postAttrs(), {"author" : this.author()}); + return new app.models.Post(_.extend(defaultAttrs, overrides)); }, postWithPoll : function(overrides) { @@ -162,7 +162,7 @@ factory = { statusMessage : function(overrides){ //intentionally doesn't have an author to mirror creation process, maybe we should change the creation process - return new app.models.StatusMessage(_.extend(factory.postAttrs(), overrides)) + return new app.models.StatusMessage(_.extend(factory.postAttrs(), overrides)); }, poll: function(overrides){ @@ -175,7 +175,7 @@ factory = { "guid" : this.guid(), "poll_id": this.id.next(), "participation_count" : 10 - } + }; }, aspectAttrs: function(overrides) { @@ -200,6 +200,6 @@ factory = { window.gon = { preloads: {} }; _.extend(window.gon.preloads, defaults, overrides); } -} +}; factory.author = factory.userAttrs; diff --git a/spec/javascripts/osmlocator-spec.js b/spec/javascripts/osmlocator-spec.js index dbd6bcf3d..f1f86d07e 100644 --- a/spec/javascripts/osmlocator-spec.js +++ b/spec/javascripts/osmlocator-spec.js @@ -3,23 +3,23 @@ describe("Locator", function(){ navigator.geolocation.getCurrentPosition = function(myCallback){ lat = 1; lon = 2; - position = { coords: { latitude: lat, longitude: lon} } + position = { coords: { latitude: lat, longitude: lon} }; return myCallback(position); }; $.getJSON = function(url, myCallback){ if(url == "https://nominatim.openstreetmap.org/reverse?format=json&lat=1&lon=2&addressdetails=3") { - return myCallback({ display_name: 'locator address' }) + return myCallback({ display_name: 'locator address' }); } - } + }; var osmlocator = new OSM.Locator(); it("should return address, latitude, and longitude using getAddress method", function(){ osmlocator.getAddress(function(display_name, coordinates){ - expect(display_name, 'locator address') - expect(coordinates, { latitude: 1, longitude: 2 }) - }) + expect(display_name, 'locator address'); + expect(coordinates, { latitude: 1, longitude: 2 }); + }); }); }); diff --git a/spec/javascripts/rails-spec.js b/spec/javascripts/rails-spec.js index ae6424a21..5808daa6a 100644 --- a/spec/javascripts/rails-spec.js +++ b/spec/javascripts/rails-spec.js @@ -23,10 +23,10 @@ describe("rails", function() { it('should not clear normal hidden fields', function(){ $('#form').trigger('ajax:success'); expect($('#standard_hidden').val()).toEqual("keep this value"); - }) + }); it('should clear hidden fields marked clear_on_submit', function(){ $('#form').trigger('ajax:success'); expect($('#clearable_hidden').val()).toEqual(""); - }) + }); }); }); diff --git a/spec/javascripts/widgets/i18n-spec.js b/spec/javascripts/widgets/i18n-spec.js index be404d73e..2315957ce 100644 --- a/spec/javascripts/widgets/i18n-spec.js +++ b/spec/javascripts/widgets/i18n-spec.js @@ -88,7 +88,7 @@ describe("Diaspora.I18n", function() { describe("::reset", function(){ it("clears the current locale", function() { Diaspora.I18n.load(locale, "en", locale); - Diaspora.I18n.reset() + Diaspora.I18n.reset(); expect(Diaspora.I18n.locale.data).toEqual({}); }); diff --git a/spec/javascripts/widgets/notifications-spec.js b/spec/javascripts/widgets/notifications-spec.js index f67955f82..9fd08458b 100644 --- a/spec/javascripts/widgets/notifications-spec.js +++ b/spec/javascripts/widgets/notifications-spec.js @@ -80,7 +80,7 @@ describe("Diaspora.Widgets.Notifications", function() { it("calls Notifications.changeNotificationCount", function() { notifications.decrementCount(); expect(notifications.changeNotificationCount).toHaveBeenCalled(); - }) + }); }); describe("incrementCount", function() { From 5fa6b8253efad64c388ec45453a6d0bd51db51c6 Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Sun, 8 Feb 2015 22:12:05 +0100 Subject: [PATCH 3/6] JSHint unused and undefined variables --- .../app/models/post/interactions.js | 8 ++-- app/assets/javascripts/app/pages/contacts.js | 2 +- app/assets/javascripts/app/pages/profile.js | 4 +- app/assets/javascripts/app/router.js | 2 +- app/assets/javascripts/app/views.js | 12 +++--- .../javascripts/app/views/bookmarklet_view.js | 6 +-- .../app/views/comment_stream_view.js | 5 +-- .../javascripts/app/views/contact_view.js | 8 ++-- .../javascripts/app/views/content_view.js | 4 +- .../app/views/faq_question_view.js | 4 +- .../javascripts/app/views/header_view.js | 2 +- .../app/views/help_section_view.js | 4 +- app/assets/javascripts/app/views/help_view.js | 6 +-- .../javascripts/app/views/hovercard_view.js | 2 +- .../javascripts/app/views/location_view.js | 6 +-- .../app/views/notifications_view.js | 17 ++++----- .../javascripts/app/views/photos_view.js | 2 +- app/assets/javascripts/app/views/poll_view.js | 2 +- .../aspect_selector_blueprint_view.js | 2 +- .../app/views/publisher/poll_creator_view.js | 3 +- .../app/views/publisher/uploader_view.js | 2 +- .../javascripts/app/views/publisher_view.js | 9 +++-- .../single_post_comment_stream.js | 6 +-- .../single_post_moderation.js | 2 - .../javascripts/app/views/stream_view.js | 5 +-- .../app/views/tag_following_action_view.js | 2 +- .../app/views/tag_following_list_view.js | 2 - app/assets/javascripts/app/views/tags_view.js | 3 +- app/assets/javascripts/diaspora.js | 2 +- app/assets/javascripts/helpers/i18n.js | 2 +- app/assets/javascripts/mobile/mobile.js | 16 ++++---- .../mobile/mobile_file_uploader.js | 9 ++--- app/assets/javascripts/osmlocator.js | 8 ++-- .../pages/users-getting-started.js | 6 +-- app/assets/javascripts/view.js | 6 +-- app/assets/javascripts/widgets/lightbox.js | 2 +- .../widgets/notifications-badge.js | 7 ++-- .../javascripts/widgets/notifications.js | 6 +-- app/assets/javascripts/widgets/timeago.js | 2 - config/jshint.yml | 38 ++++++++++++++++--- .../javascripts/posix-bracket-expressions.js | 3 ++ spec/javascripts/app/router_spec.js | 6 +-- .../app/views/comment_stream_view_spec.js | 2 +- .../app/views/notifications_view_spec.js | 8 ++-- .../app/views/publisher_view_spec.js | 4 +- .../javascripts/app/views/stream_post_spec.js | 4 +- spec/javascripts/diaspora-spec.js | 8 ++-- spec/javascripts/helpers/SpecHelper.js | 9 +++-- spec/javascripts/helpers/factory.js | 8 ++-- spec/javascripts/helpers/mock-ajax.js | 2 +- spec/javascripts/osmlocator-spec.js | 6 +-- spec/javascripts/search-spec.js | 1 + spec/javascripts/widgets/lightbox-spec.js | 6 +-- spec/javascripts/widgets/search-spec.js | 2 +- 54 files changed, 164 insertions(+), 141 deletions(-) diff --git a/app/assets/javascripts/app/models/post/interactions.js b/app/assets/javascripts/app/models/post/interactions.js index b9e56f169..4ba54e014 100644 --- a/app/assets/javascripts/app/models/post/interactions.js +++ b/app/assets/javascripts/app/models/post/interactions.js @@ -72,7 +72,7 @@ app.models.Post.Interactions = Backbone.Model.extend({ unlike : function() { var self = this; - this.userLike().destroy({success : function(model, resp) { + this.userLike().destroy({success : function() { self.trigger('change'); self.set({"likes_count" : self.get("likes_count") - 1}); }}); @@ -84,7 +84,7 @@ app.models.Post.Interactions = Backbone.Model.extend({ var self = this; this.comments.make(text).fail(function () { - flash = new Diaspora.Widgets.FlashMessages(); + var flash = new Diaspora.Widgets.FlashMessages(); flash.render({ success: false, notice: Diaspora.I18n.t("failed_to_post_message") @@ -104,13 +104,13 @@ app.models.Post.Interactions = Backbone.Model.extend({ , flash = new Diaspora.Widgets.FlashMessages(); reshare.save({}, { - success : function(resp){ + success : function(){ flash.render({ success: true, notice: Diaspora.I18n.t("reshares.successful") }); }, - error: function(resp){ + error: function(){ flash.render({ success: false, notice: Diaspora.I18n.t("reshares.duplicate") diff --git a/app/assets/javascripts/app/pages/contacts.js b/app/assets/javascripts/app/pages/contacts.js index ac4478394..996a5898b 100644 --- a/app/assets/javascripts/app/pages/contacts.js +++ b/app/assets/javascripts/app/pages/contacts.js @@ -60,7 +60,7 @@ app.pages.Contacts = Backbone.View.extend({ $(".header > #aspect_name_form").show(); }, - updateAspectName: function(evt,data,status,xhr){ + updateAspectName: function(evt,data){ $(".header #aspect_name").text(data['name']); $("#aspect_nav [data-aspect-id='"+data['id']+"'] .name").text(data['name']); $(".header > #aspect_name_form").hide(); diff --git a/app/assets/javascripts/app/pages/profile.js b/app/assets/javascripts/app/pages/profile.js index 55d163961..767c9f3a2 100644 --- a/app/assets/javascripts/app/pages/profile.js +++ b/app/assets/javascripts/app/pages/profile.js @@ -92,7 +92,7 @@ app.pages.Profile = app.views.Base.extend({ return new view({model: app.stream}); }, - blockPerson: function(evt) { + blockPerson: function() { if( !confirm(Diaspora.I18n.t('ignore_user')) ) return; var block = this.model.block(); @@ -106,7 +106,7 @@ app.pages.Profile = app.views.Base.extend({ return false; }, - unblockPerson: function(evt) { + unblockPerson: function() { var block = this.model.unblock(); block.fail(function() { Diaspora.page.flashMessages.render({ diff --git a/app/assets/javascripts/app/router.js b/app/assets/javascripts/app/router.js index 4e5e6d36c..7b2d4db10 100644 --- a/app/assets/javascripts/app/router.js +++ b/app/assets/javascripts/app/router.js @@ -75,7 +75,7 @@ app.Router = Backbone.Router.extend({ //below here is oldness - stream : function(page) { + stream : function() { app.stream = new app.models.Stream(); app.stream.fetch(); app.page = new app.views.Stream({model : app.stream}); diff --git a/app/assets/javascripts/app/views.js b/app/assets/javascripts/app/views.js index ef7f82533..55ec8fffc 100644 --- a/app/assets/javascripts/app/views.js +++ b/app/assets/javascripts/app/views.js @@ -2,7 +2,7 @@ app.views.Base = Backbone.View.extend({ - initialize : function(options) { + initialize : function() { this.setupRenderEvents(); }, @@ -76,8 +76,6 @@ app.views.Base = Backbone.View.extend({ }, setFormAttrs : function(){ - this.model.set(_.inject(this.formAttrs, _.bind(setValueFromField, this), {})); - function setValueFromField(memo, attribute, selector){ if(attribute.slice("-2") === "[]") { memo[attribute.slice(0, attribute.length - 2)] = _.pluck(this.$el.find(selector).serializeArray(), "value"); @@ -86,6 +84,8 @@ app.views.Base = Backbone.View.extend({ } return memo; } + + this.model.set(_.inject(this.formAttrs, _.bind(setValueFromField, this), {})); }, report: function(evt) { @@ -104,13 +104,13 @@ app.views.Base = Backbone.View.extend({ var report = new app.models.Report(); report.save(data, { - success: function(model, response) { + success: function() { Diaspora.page.flashMessages.render({ success: true, notice: Diaspora.I18n.t('report.status.created') }); }, - error: function(model, response) { + error: function() { Diaspora.page.flashMessages.render({ success: false, notice: Diaspora.I18n.t('report.status.exists') @@ -142,7 +142,7 @@ app.views.Base = Backbone.View.extend({ }, avatars: { - fallback: function(evt) { + fallback: function() { $(this).attr("src", ImagePaths.get("user/default.png")); }, selector: "img.avatar" diff --git a/app/assets/javascripts/app/views/bookmarklet_view.js b/app/assets/javascripts/app/views/bookmarklet_view.js index e3757719a..c8e982fc3 100644 --- a/app/assets/javascripts/app/views/bookmarklet_view.js +++ b/app/assets/javascripts/app/views/bookmarklet_view.js @@ -30,18 +30,18 @@ app.views.Bookmarklet = Backbone.View.extend({ return contents; }, - _postSubmit: function(evt) { + _postSubmit: function() { this.$('h4').text(Diaspora.I18n.t('bookmarklet.post_submit')); }, - _postSuccess: function(evt) { + _postSuccess: function() { this.$('h4').text(Diaspora.I18n.t('bookmarklet.post_success')); app.publisher.close(); this.$("#publisher").addClass("hidden"); _.delay(window.close, 2000); }, - _postError: function(evt) { + _postError: function() { this.$('h4').text(Diaspora.I18n.t('bookmarklet.post_something')); } }); diff --git a/app/assets/javascripts/app/views/comment_stream_view.js b/app/assets/javascripts/app/views/comment_stream_view.js index c694f1cac..425654d93 100644 --- a/app/assets/javascripts/app/views/comment_stream_view.js +++ b/app/assets/javascripts/app/views/comment_stream_view.js @@ -73,7 +73,7 @@ app.views.CommentStream = app.views.Base.extend({ }).render().el); }, - commentTextareaFocused: function(evt){ + commentTextareaFocused: function(){ this.$("form").removeClass('hidden').addClass("open"); }, @@ -83,8 +83,7 @@ app.views.CommentStream = app.views.Base.extend({ expandComments: function(evt){ if(evt){ evt.preventDefault(); } - - self = this; + var self = this; this.model.comments.fetch({ success : function(resp){ diff --git a/app/assets/javascripts/app/views/contact_view.js b/app/assets/javascripts/app/views/contact_view.js index 297bec059..ce07dc55d 100644 --- a/app/assets/javascripts/app/views/contact_view.js +++ b/app/assets/javascripts/app/views/contact_view.js @@ -44,10 +44,10 @@ app.views.Contact = app.views.Base.extend({ 'person_id': this.model.get('person_id'), 'aspect_id': app.aspect.get('id') },{ - success: function(model,response){ + success: function(){ self.render(); }, - error: function(model,response){ + error: function(){ var msg = Diaspora.I18n.t('contacts.error_add', { 'name': self.model.get('person').name }); Diaspora.page.flashMessages.render({ 'success':false, 'notice':msg }); } @@ -59,10 +59,10 @@ app.views.Contact = app.views.Base.extend({ this.model.aspect_memberships .find(function(membership){ return membership.get('aspect').id == app.aspect.id; }) .destroy({ - success: function(model,response){ + success: function(){ self.render(); }, - error: function(model,response){ + error: function(){ var msg = Diaspora.I18n.t('contacts.error_remove', { 'name': self.model.get('person').name }); Diaspora.page.flashMessages.render({ 'success':false, 'notice':msg }); } diff --git a/app/assets/javascripts/app/views/content_view.js b/app/assets/javascripts/app/views/content_view.js index 13816e34e..a7cbc8f63 100644 --- a/app/assets/javascripts/app/views/content_view.js +++ b/app/assets/javascripts/app/views/content_view.js @@ -95,9 +95,9 @@ app.views.OEmbed = app.views.Base.extend({ }, presenter:function () { - o_embed_cache = this.model.get("o_embed_cache"); + var o_embed_cache = this.model.get("o_embed_cache"); if(o_embed_cache) { - typemodel = { rich: false, photo: false, video: false, link: false }; + var typemodel = { rich: false, photo: false, video: false, link: false }; typemodel[o_embed_cache.data.type] = true; o_embed_cache.data.types = typemodel; } diff --git a/app/assets/javascripts/app/views/faq_question_view.js b/app/assets/javascripts/app/views/faq_question_view.js index a4a2303b3..f32969e32 100644 --- a/app/assets/javascripts/app/views/faq_question_view.js +++ b/app/assets/javascripts/app/views/faq_question_view.js @@ -28,8 +28,8 @@ app.views.FaqQuestionView = app.views.Base.extend({ }, toggled: function(e) { - el = $(e.target); - parent = el.parents('.question'); + var el = $(e.target); + var parent = el.parents('.question'); parent.children('.answer').toggle(); parent.toggleClass('opened').toggleClass('collapsed'); diff --git a/app/assets/javascripts/app/views/header_view.js b/app/assets/javascripts/app/views/header_view.js index a526c5fcd..31e591769 100644 --- a/app/assets/javascripts/app/views/header_view.js +++ b/app/assets/javascripts/app/views/header_view.js @@ -12,7 +12,7 @@ app.views.Header = app.views.Base.extend({ "focusout #q": "toggleSearchActive" }, - initialize : function(options) { + initialize : function() { $(document.body).click($.proxy(this.hideDropdown, this)); return this; }, diff --git a/app/assets/javascripts/app/views/help_section_view.js b/app/assets/javascripts/app/views/help_section_view.js index 0d17b318f..432179461 100644 --- a/app/assets/javascripts/app/views/help_section_view.js +++ b/app/assets/javascripts/app/views/help_section_view.js @@ -26,8 +26,8 @@ app.views.HelpSectionView = app.views.StaticContentView.extend({ }, toggled: function(e) { - el = $(e.target); - parent = el.parents('.question'); + var el = $(e.target); + var parent = el.parents('.question'); parent.children('.answer.hideable').toggle(); parent.toggleClass('opened').toggleClass('collapsed'); diff --git a/app/assets/javascripts/app/views/help_view.js b/app/assets/javascripts/app/views/help_view.js index c2c586adf..4df60c68f 100644 --- a/app/assets/javascripts/app/views/help_view.js +++ b/app/assets/javascripts/app/views/help_view.js @@ -12,7 +12,7 @@ app.views.Help = app.views.StaticContentView.extend({ "click .faq-link-keyboard-shortcuts" : "keyboardShortcuts", }, - initialize : function(options) { + initialize : function() { this.GETTING_HELP_SUBS = { getting_started_a: { tutorial_series: this.linkHtml("http://diasporafoundation.org/getting_started/sign_up", Diaspora.I18n.t( 'getting_started_tutorial' )) }, get_support_a_website: { link: this.linkHtml("https://diasporafoundation.org/", Diaspora.I18n.t( 'foundation_website' ))}, @@ -124,8 +124,8 @@ app.views.Help = app.views.StaticContentView.extend({ renderStaticSection: function(section, template, subs) { this.clearItems(); - data = $.extend(Diaspora.I18n.resolve(section), { className: section }); - help_section = new app.views.HelpSectionView({ + var data = $.extend(Diaspora.I18n.resolve(section), { className: section }); + var help_section = new app.views.HelpSectionView({ template: template, data: data, subs: subs diff --git a/app/assets/javascripts/app/views/hovercard_view.js b/app/assets/javascripts/app/views/hovercard_view.js index b113e2ce6..c6adc0a71 100644 --- a/app/assets/javascripts/app/views/hovercard_view.js +++ b/app/assets/javascripts/app/views/hovercard_view.js @@ -129,7 +129,7 @@ app.views.Hovercard = app.views.Base.extend({ $.get(href, function(response) { self.dropdown_container.html(response); }); - var aspect_membership = new app.views.AspectMembership({el: self.dropdown_container}); + new app.views.AspectMembership({el: self.dropdown_container}); }, _positionHovercard: function() { diff --git a/app/assets/javascripts/app/views/location_view.js b/app/assets/javascripts/app/views/location_view.js index dfb4a5cfe..bf7ff3811 100644 --- a/app/assets/javascripts/app/views/location_view.js +++ b/app/assets/javascripts/app/views/location_view.js @@ -13,10 +13,10 @@ app.views.Location = Backbone.View.extend({ $(this.el).append('delete location'); }, - 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/photos_view.js b/app/assets/javascripts/app/views/photos_view.js index 2870f6446..5d5969ef1 100644 --- a/app/assets/javascripts/app/views/photos_view.js +++ b/app/assets/javascripts/app/views/photos_view.js @@ -1,7 +1,7 @@ // @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; 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/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/poll_creator_view.js b/app/assets/javascripts/app/views/publisher/poll_creator_view.js index 45920b2c8..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'); }, diff --git a/app/assets/javascripts/app/views/publisher/uploader_view.js b/app/assets/javascripts/app/views/publisher/uploader_view.js index b8218fed9..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(); }, diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 86143412e..c27637d45 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -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 }); @@ -271,9 +271,10 @@ app.views.Publisher = Backbone.View.extend({ ); }); - var mentioned_people = []; - var regexp = new RegExp("@{\(\[\^\;\]\+\); \(\[\^\}\]\+\)}", "g"); - while(user=regexp.exec(serializedForm["status_message[text]"])){ + var mentioned_people = [], + regexp = new RegExp("@{\(\[\^\;\]\+\); \(\[\^\}\]\+\)}", "g"), + user; + 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]; if(mentioned_user){ 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 497a8e83a..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,11 +9,11 @@ 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}); } }, 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 15062c651..655acec8a 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(), }); diff --git a/app/assets/javascripts/app/views/stream_view.js b/app/assets/javascripts/app/views/stream_view.js index 940b5a401..9d5d036ca 100644 --- a/app/assets/javascripts/app/views/stream_view.js +++ b/app/assets/javascripts/app/views/stream_view.js @@ -5,7 +5,7 @@ app.views.Stream = app.views.InfScroll.extend(_.extend( app.views.StreamShortcuts, { - initialize: function(options) { + initialize: function() { this.stream = this.model; this.collection = this.stream.items; @@ -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() }); } + app.currentUser.bind("nsfwChanged", reRenderPostViews, this); }, markNavSelected : function() { 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 3475bc545..37d95ff2a 100644 --- a/app/assets/javascripts/app/views/tag_following_action_view.js +++ b/app/assets/javascripts/app/views/tag_following_action_view.js @@ -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); 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 a44f3e296..f1413ffea 100644 --- a/app/assets/javascripts/app/views/tag_following_list_view.js +++ b/app/assets/javascripts/app/views/tag_following_list_view.js @@ -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/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/diaspora.js b/app/assets/javascripts/diaspora.js index de5a97900..054905786 100644 --- a/app/assets/javascripts/diaspora.js +++ b/app/assets/javascripts/diaspora.js @@ -42,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; diff --git a/app/assets/javascripts/helpers/i18n.js b/app/assets/javascripts/helpers/i18n.js index 3e4a01fe0..ece2fd386 100644 --- a/app/assets/javascripts/helpers/i18n.js +++ b/app/assets/javascripts/helpers/i18n.js @@ -20,7 +20,7 @@ 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 !== "") { eval("locale.pluralizationKey = "+rule); } diff --git a/app/assets/javascripts/mobile/mobile.js b/app/assets/javascripts/mobile/mobile.js index 9e64978e9..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') ) { @@ -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"); @@ -264,7 +264,7 @@ $(document).ready(function(){ }); - $(".service_icon").bind("tap click", function(evt) { + $(".service_icon").bind("tap click", function() { var service = $(this).toggleClass("dim"), selectedServices = $("#new_status_message .service_icon:not(.dim)"), provider = service.attr("id"), diff --git a/app/assets/javascripts/mobile/mobile_file_uploader.js b/app/assets/javascripts/mobile/mobile_file_uploader.js index bd92d1c6b..1084821e9 100644 --- a/app/assets/javascripts/mobile/mobile_file_uploader.js +++ b/app/assets/javascripts/mobile/mobile_file_uploader.js @@ -5,7 +5,7 @@ function createUploader(){ var aspectIds = gon.preloads.aspect_ids; - var uploader = new qq.FileUploaderBasic({ + new qq.FileUploaderBasic({ element: document.getElementById('file-upload-publisher'), params: {'photo' : {'pending' : 'true', 'aspect_ids' : aspectIds},}, allowedExtensions: ['jpg', 'jpeg', 'png', 'gif', 'tiff'], @@ -25,7 +25,7 @@ function createUploader(){ emptyError: Diaspora.I18n.t("photo_uploader.new_photo.empty") }, - onSubmit: function(id, fileName){ + onSubmit: function(){ $('#file-upload-publisher').addClass("loading"); $('#publisher_textarea_wrapper').addClass("with_attachments"); $('#photodropzone').append( @@ -53,8 +53,7 @@ function createUploader(){ "
    "); //// - var publisher = $('#publisher'), - textarea = publisher.find('textarea'); + var publisher = $('#publisher'); publisher.find("input[type='submit']").removeAttr('disabled'); @@ -76,7 +75,7 @@ function createUploader(){ }); }, - onAllComplete: function(completed_files){ + onAllComplete: function(){ } }); diff --git a/app/assets/javascripts/osmlocator.js b/app/assets/javascripts/osmlocator.js index e5517b768..157230456 100644 --- a/app/assets/javascripts/osmlocator.js +++ b/app/assets/javascripts/osmlocator.js @@ -6,15 +6,15 @@ OSM.Locator = function(){ var geolocalize = function(callback){ navigator.geolocation.getCurrentPosition(function(position) { - lat=position.coords.latitude; - lon=position.coords.longitude; - var display_name =$.getJSON("https://nominatim.openstreetmap.org/reverse?format=json&lat="+lat+"&lon="+lon+"&addressdetails=3", function(data){ + var lat=position.coords.latitude, + lon=position.coords.longitude; + $.getJSON("https://nominatim.openstreetmap.org/reverse?format=json&lat="+lat+"&lon="+lon+"&addressdetails=3", function(data){ return callback(data.display_name, position.coords); }); },errorGettingPosition); }; - function errorGettingPosition(err) { + function errorGettingPosition() { $("#location").remove(); } diff --git a/app/assets/javascripts/pages/users-getting-started.js b/app/assets/javascripts/pages/users-getting-started.js index d4f0954ce..deeb97fdb 100644 --- a/app/assets/javascripts/pages/users-getting-started.js +++ b/app/assets/javascripts/pages/users-getting-started.js @@ -7,12 +7,12 @@ Diaspora.Pages.UsersGettingStarted = function() { self.peopleSearch = self.instantiate("Search", body.find("form.people.search_form")); self.tagSearch = self.instantiate("Search", body.find("form.tag_input.search_form")); - $('#edit_profile').bind('ajax:success', function(evt, data, status, xhr){ + $('#edit_profile').bind('ajax:success', function(){ $('#gs-name-form-spinner').addClass("hidden"); }); // It seems that the default behavior of rails ujs is to clear the remote form - $('#edit_profile').bind('ajax:complete', function(evt, xhr, status){ + $('#edit_profile').bind('ajax:complete', function(){ var firstNameField = $("#profile_first_name"); firstNameField.val(firstNameField.data("cachedValue")); @@ -35,7 +35,7 @@ Diaspora.Pages.UsersGettingStarted = function() { $(this).addClass("active_input"); }); - $("#awesome_button").bind("click", function(evt){ + $("#awesome_button").bind("click", function(){ var confirmMessage = Diaspora.I18n.t("getting_started.no_tags"); var message = Diaspora.I18n.t("getting_started.preparing_your_stream"); var confirmation = true; diff --git a/app/assets/javascripts/view.js b/app/assets/javascripts/view.js index 9ce4e6a90..33acba38a 100644 --- a/app/assets/javascripts/view.js +++ b/app/assets/javascripts/view.js @@ -45,13 +45,13 @@ var View = { }); }; - $(document).on('ajax:success', 'form[data-remote]', function (e) { + $(document).on('ajax:success', 'form[data-remote]', function () { $(this).clearForm(); $(this).focusout(); }); /* tag following */ - $("#new_tag_following .tag_input").bind('focus', function(evt){ + $("#new_tag_following .tag_input").bind('focus', function(){ $(this).siblings("#tag_following_submit").removeClass('hidden'); }); @@ -62,7 +62,7 @@ var View = { Diaspora.page.directionDetector.updateBinds(); }); - $("a.new_aspect").click(function(e){ + $("a.new_aspect").click(function(){ $("input#aspect_name").focus(); }); diff --git a/app/assets/javascripts/widgets/lightbox.js b/app/assets/javascripts/widgets/lightbox.js index b2b91922b..f2f008fad 100644 --- a/app/assets/javascripts/widgets/lightbox.js +++ b/app/assets/javascripts/widgets/lightbox.js @@ -27,7 +27,7 @@ jQuery.fn.center = (function() { imageSelector: 'img.stream-photo' }; - this.subscribe("widget/ready", function(evt) { + this.subscribe("widget/ready", function() { $.extend(self, { lightbox: $("#lightbox"), navigation: $("#lightbox-navigation"), diff --git a/app/assets/javascripts/widgets/notifications-badge.js b/app/assets/javascripts/widgets/notifications-badge.js index c24cd80f1..bb2ec580d 100644 --- a/app/assets/javascripts/widgets/notifications-badge.js +++ b/app/assets/javascripts/widgets/notifications-badge.js @@ -85,10 +85,10 @@ }); self.dropdownNotifications.find("time.timeago").timeago(); - self.dropdownNotifications.find('.unread').each(function(index) { + self.dropdownNotifications.find('.unread').each(function() { Diaspora.page.header.notifications.setUpUnread( $(this) ); }); - self.dropdownNotifications.find('.read').each(function(index) { + self.dropdownNotifications.find('.read').each(function() { Diaspora.page.header.notifications.setUpRead( $(this) ); }); $('.notifications').perfectScrollbar('destroy'); @@ -97,7 +97,7 @@ isLoading = false; $('.notifications').removeClass("loading"); //Infinite Scrolling - $('.notifications').scroll(function(e) { + $('.notifications').scroll(function() { var bottom = $('.notifications').prop('scrollHeight') - $('.notifications').height(); var currentPosition = $('.notifications').scrollTop(); isLoading = ($('.loading').length == 1); @@ -113,4 +113,3 @@ Diaspora.Widgets.NotificationsDropdown = NotificationDropdown; })(); // @license-end - diff --git a/app/assets/javascripts/widgets/notifications.js b/app/assets/javascripts/widgets/notifications.js index 226788bfe..59c6f78f6 100644 --- a/app/assets/javascripts/widgets/notifications.js +++ b/app/assets/javascripts/widgets/notifications.js @@ -29,7 +29,7 @@ type: "GET", dataType:'json', success: function(){ - self.notificationMenu.find('.unread').each(function(index) { + self.notificationMenu.find('.unread').each(function() { self.setUpRead( $(this) ); }); self.resetCount(); @@ -83,7 +83,7 @@ this.clickSuccess = function( data ) { var itemID = data["guid"]; var isUnread = data["unread"]; - self.notificationMenu.find('.read,.unread').each(function(index) { + self.notificationMenu.find('.read,.unread').each(function() { if ( $(this).data("guid") == itemID ) { if ( isUnread ) { self.notificationMenu.find('a#mark_all_read_link').removeClass('disabled'); @@ -128,7 +128,7 @@ self.badge.removeClass("hidden"); } }; - this.resetCount = function(change) { + this.resetCount = function() { self.count = 0; this.changeNotificationCount(0); }; diff --git a/app/assets/javascripts/widgets/timeago.js b/app/assets/javascripts/widgets/timeago.js index e6146781a..deb233afc 100644 --- a/app/assets/javascripts/widgets/timeago.js +++ b/app/assets/javascripts/widgets/timeago.js @@ -6,8 +6,6 @@ */ (function() { Diaspora.Widgets.TimeAgo = function() { - var self = this; - this.subscribe("widget/ready", function() { if(Diaspora.I18n.language !== "en") { $.timeago.settings.lang = Diaspora.I18n.language; diff --git a/config/jshint.yml b/config/jshint.yml index ae1bae9b0..571c0c100 100644 --- a/config/jshint.yml +++ b/config/jshint.yml @@ -15,22 +15,26 @@ options: freeze: true immed: true indent: 2 - latedef: nofunc + latedef: true newcap: false noarg: true noempty: true nonbsp: true nonew: false notypeof: true - undef: false - unused: false + undef: true + unused: true # relaxing options asi: false boss: true + browser: true + devel: true eqnull: true evil: true expr: true + jasmine: true + jquery: true lastsemic: true laxbreak: true laxcomma: true @@ -40,5 +44,29 @@ options: supernew: true globals: - jQuery: true - "$": true + "_": true + "Backbone": true + "gon": true + "Handlebars": true + "HandlebarsTemplates": true + "ImagePaths": true + "jsxc": true + "MBP": true + "Routes": true + "OSM": true + "parse_url": true + "punycode": true + "qq": true + + "loginAs": true + "logout": true + "spec": true + "context": true + "factory": true + "stubView": true + "exports": true + + "app": true + "Diaspora": true + "Mentions": true + "PosixBracketExpressions": true diff --git a/lib/assets/javascripts/posix-bracket-expressions.js b/lib/assets/javascripts/posix-bracket-expressions.js index b071fdcd6..4f573e5b6 100644 --- a/lib/assets/javascripts/posix-bracket-expressions.js +++ b/lib/assets/javascripts/posix-bracket-expressions.js @@ -1,5 +1,8 @@ // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later +// information for jshint +/* exported PosixBracketExpressions */ + var PosixBracketExpressions = { alnum : '\\u0030-\\u0039' + '\\u0041-\\u005a' diff --git a/spec/javascripts/app/router_spec.js b/spec/javascripts/app/router_spec.js index 3beac1f07..259105d30 100644 --- a/spec/javascripts/app/router_spec.js +++ b/spec/javascripts/app/router_spec.js @@ -6,7 +6,7 @@ describe('app.Router', function () { it('decodes name before passing it into TagFollowingAction', function () { var followed_tags = spyOn(app.router, 'followed_tags').and.callThrough(); - var tag_following_action = spyOn(app.views, 'TagFollowingAction').and.callFake(function(data) { + var tag_following_action = spyOn(app.views, 'TagFollowingAction').and.callFake(function() { return {render: function() { return {el: ""}}}; }); @@ -17,7 +17,7 @@ describe('app.Router', function () { it('navigates to the downcase version of the corresponding tag', function () { var followed_tags = spyOn(app.router, 'followed_tags').and.callThrough(); - var tag_following_action = spyOn(app.views, 'TagFollowingAction').and.callFake(function(data) { + var tag_following_action = spyOn(app.views, 'TagFollowingAction').and.callFake(function() { return {render: function() { return {el: ""}}}; }); @@ -63,7 +63,7 @@ describe('app.Router', function () { describe("bookmarklet", function() { it('routes to bookmarklet even if params have linefeeds', function() { - router = new app.Router(); + var router = new app.Router(); var route = jasmine.createSpy('bookmarklet route'); router.on('route:bookmarklet', route); router.navigate("/bookmarklet?\n\nfeefwefwewef\n", {trigger: true}); diff --git a/spec/javascripts/app/views/comment_stream_view_spec.js b/spec/javascripts/app/views/comment_stream_view_spec.js index 8ed0592c4..c5cf4cce6 100644 --- a/spec/javascripts/app/views/comment_stream_view_spec.js +++ b/spec/javascripts/app/views/comment_stream_view_spec.js @@ -44,7 +44,7 @@ describe("app.views.CommentStream", function(){ }); it("fires an AJAX request", function() { - params = JSON.parse(this.request.params); + var params = JSON.parse(this.request.params); // TODO: use this, once jasmine-ajax is updated to latest version //params = this.request.data(); diff --git a/spec/javascripts/app/views/notifications_view_spec.js b/spec/javascripts/app/views/notifications_view_spec.js index 12034e4a6..34312118a 100644 --- a/spec/javascripts/app/views/notifications_view_spec.js +++ b/spec/javascripts/app/views/notifications_view_spec.js @@ -40,8 +40,8 @@ describe("app.views.Notifications", function(){ }); it('changes the "all notifications" count', function() { - badge = $('ul.nav > li:eq(0) .badge'); - count = parseInt(badge.text()); + var badge = $('ul.nav > li:eq(0) .badge'); + var count = parseInt(badge.text()); this.view.updateView(this.guid, this.type, true); expect(parseInt(badge.text())).toBe(count + 1); @@ -51,8 +51,8 @@ describe("app.views.Notifications", function(){ }); it('changes the notification type count', function() { - badge = $('ul.nav > li[data-type=' + this.type + '] .badge'); - count = parseInt(badge.text()); + var badge = $('ul.nav > li[data-type=' + this.type + '] .badge'); + var count = parseInt(badge.text()); this.view.updateView(this.guid, this.type, true); expect(parseInt(badge.text())).toBe(count + 1); diff --git a/spec/javascripts/app/views/publisher_view_spec.js b/spec/javascripts/app/views/publisher_view_spec.js index ca38368bc..b52e9d678 100644 --- a/spec/javascripts/app/views/publisher_view_spec.js +++ b/spec/javascripts/app/views/publisher_view_spec.js @@ -417,7 +417,7 @@ describe("app.views.Publisher", function() { describe('#avoidEnter', function(){ it("Avoid submitting the form when pressing enter", function(){ // simulates the event object - evt = {}; + var evt = {}; evt.keyCode = 13; // should return false in order to avoid the form submition @@ -443,7 +443,7 @@ describe("app.views.Publisher", function() { it('initializes the file uploader plugin', function() { spyOn(qq, 'FileUploaderBasic'); - var publisher = new app.views.Publisher(); + new app.views.Publisher(); expect(qq.FileUploaderBasic).toHaveBeenCalled(); }); diff --git a/spec/javascripts/app/views/stream_post_spec.js b/spec/javascripts/app/views/stream_post_spec.js index e26618492..e660db727 100644 --- a/spec/javascripts/app/views/stream_post_spec.js +++ b/spec/javascripts/app/views/stream_post_spec.js @@ -10,7 +10,7 @@ describe("app.views.StreamPost", function(){ describe("events", function(){ var _PostViewClass, - author_id; + authorId; beforeEach(function(){ _PostViewClass = this.PostViewClass; @@ -20,7 +20,7 @@ describe("app.views.StreamPost", function(){ describe("remove posts for blocked person", function(){ it("setup remove:author:posts:#{id} to #remove", function(){ spyOn(_PostViewClass.prototype, 'remove'); - view = new _PostViewClass({model : this.statusMessage}); + new _PostViewClass({model : this.statusMessage}); app.events.trigger('person:block:'+authorId); expect(_PostViewClass.prototype.remove).toHaveBeenCalled(); }); diff --git a/spec/javascripts/diaspora-spec.js b/spec/javascripts/diaspora-spec.js index 3376c1e45..944ee6ea7 100644 --- a/spec/javascripts/diaspora-spec.js +++ b/spec/javascripts/diaspora-spec.js @@ -57,8 +57,8 @@ describe("Diaspora", function() { describe("subscribe", function() { it("will subscribe to multiple events", function() { var firstEventCalled = false, - secondEventCalled = false; - events = Diaspora.EventBroker.extend({}); + secondEventCalled = false, + events = Diaspora.EventBroker.extend({}); events.subscribe("first/event second/event", function() { if (firstEventCalled) { @@ -78,8 +78,8 @@ describe("Diaspora", function() { describe("publish", function() { it("will publish multiple events", function() { var firstEventCalled = false, - secondEventCalled = false; - events = Diaspora.EventBroker.extend({}); + secondEventCalled = false, + events = Diaspora.EventBroker.extend({}); events.subscribe("first/event second/event", function() { if (firstEventCalled) { diff --git a/spec/javascripts/helpers/SpecHelper.js b/spec/javascripts/helpers/SpecHelper.js index 14bf5d491..0730ab771 100644 --- a/spec/javascripts/helpers/SpecHelper.js +++ b/spec/javascripts/helpers/SpecHelper.js @@ -4,7 +4,7 @@ var realXMLHttpRequest = window.XMLHttpRequest; // matches flash messages with success/error and contained text var flashMatcher = function(flash, id, text) { - textContained = true; + var textContained = true; if( text ) { textContained = (flash.text().indexOf(text) !== -1); } @@ -14,10 +14,13 @@ var flashMatcher = function(flash, id, text) { textContained; }; +// information for jshint +/* exported context */ var context = describe; + var spec = {}; var customMatchers = { - toBeSuccessFlashMessage: function(util) { + toBeSuccessFlashMessage: function() { return { compare: function(actual, expected) { var result = {}; @@ -26,7 +29,7 @@ var customMatchers = { } }; }, - toBeErrorFlashMessage: function(util) { + toBeErrorFlashMessage: function() { return { compare: function(actual, expected) { var result = {}; diff --git a/spec/javascripts/helpers/factory.js b/spec/javascripts/helpers/factory.js index e52cb683c..c3efcafb7 100644 --- a/spec/javascripts/helpers/factory.js +++ b/spec/javascripts/helpers/factory.js @@ -1,4 +1,4 @@ -factory = { +var factory = { id : { current : 0, next : function(){ @@ -149,12 +149,12 @@ factory = { }, post : function(overrides) { - defaultAttrs = _.extend(factory.postAttrs(), {"author" : this.author()}); + var defaultAttrs = _.extend(factory.postAttrs(), {"author" : this.author()}); return new app.models.Post(_.extend(defaultAttrs, overrides)); }, postWithPoll : function(overrides) { - defaultAttrs = _.extend(factory.postAttrs(), {"author" : this.author()}); + var defaultAttrs = _.extend(factory.postAttrs(), {"author" : this.author()}); defaultAttrs = _.extend(defaultAttrs, {"already_participated_in_poll" : false}); defaultAttrs = _.extend(defaultAttrs, {"poll" : factory.poll()}); return new app.models.Post(_.extend(defaultAttrs, overrides)); @@ -165,7 +165,7 @@ factory = { return new app.models.StatusMessage(_.extend(factory.postAttrs(), overrides)); }, - poll: function(overrides){ + poll: function(){ return { "question" : "This is an awesome question", "created_at" : "2012-01-03T19:53:13Z", diff --git a/spec/javascripts/helpers/mock-ajax.js b/spec/javascripts/helpers/mock-ajax.js index dad561469..fd8aa2f65 100644 --- a/spec/javascripts/helpers/mock-ajax.js +++ b/spec/javascripts/helpers/mock-ajax.js @@ -130,7 +130,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. onload: function() { }, - onreadystatechange: function(isTimeout) { + onreadystatechange: function() { }, status: null, diff --git a/spec/javascripts/osmlocator-spec.js b/spec/javascripts/osmlocator-spec.js index f1f86d07e..fbb92a120 100644 --- a/spec/javascripts/osmlocator-spec.js +++ b/spec/javascripts/osmlocator-spec.js @@ -1,9 +1,9 @@ describe("Locator", function(){ navigator.geolocation = {}; navigator.geolocation.getCurrentPosition = function(myCallback){ - lat = 1; - lon = 2; - position = { coords: { latitude: lat, longitude: lon} }; + var lat = 1; + var lon = 2; + var position = { coords: { latitude: lat, longitude: lon} }; return myCallback(position); }; diff --git a/spec/javascripts/search-spec.js b/spec/javascripts/search-spec.js index 99f018dbf..ba767fe88 100644 --- a/spec/javascripts/search-spec.js +++ b/spec/javascripts/search-spec.js @@ -4,6 +4,7 @@ */ describe("List", function() { + /* global List */ describe("runDelayedSearch", function() { beforeEach( function(){ spec.loadFixture('empty_people_search'); diff --git a/spec/javascripts/widgets/lightbox-spec.js b/spec/javascripts/widgets/lightbox-spec.js index 2ca0dfaad..52d5ee7f9 100644 --- a/spec/javascripts/widgets/lightbox-spec.js +++ b/spec/javascripts/widgets/lightbox-spec.js @@ -13,7 +13,7 @@ describe("Diaspora.Widgets.Lightbox", function() { imageClass: 'stream-photo' }; - classes = _.extend(defaults, opts); + var classes = _.extend(defaults, opts); var output = $('
    ').addClass(classes.imageParent); _.each(photos, function(photo){ @@ -48,7 +48,7 @@ describe("Diaspora.Widgets.Lightbox", function() { }); context("opens the lightbox correctly", function() { - var lightbox, page, photoElement; + var lightbox, photoElement; beforeEach(function() { $("#jasmine_content").append(createDummyMarkup()); @@ -67,7 +67,7 @@ describe("Diaspora.Widgets.Lightbox", function() { }); context("opens lightbox for differently named elements", function(){ - var lightbox, page, photoElement; + var lightbox, photoElement; beforeEach(function() { $("#jasmine_content").append(createDummyMarkup({ diff --git a/spec/javascripts/widgets/search-spec.js b/spec/javascripts/widgets/search-spec.js index e1f831af6..4f1fb659a 100644 --- a/spec/javascripts/widgets/search-spec.js +++ b/spec/javascripts/widgets/search-spec.js @@ -5,7 +5,7 @@ describe("Diaspora.Widgets.Search", function() { var search = Diaspora.BaseWidget.instantiate("Search", $("#jasmine_content > #searchForm")); var person = {"name": "