From df440ed8d827022566c84200d99b80f1efb438ea Mon Sep 17 00:00:00 2001 From: "Spanti Nicola (RyDroid)" Date: Wed, 8 Jul 2015 02:06:23 +0200 Subject: [PATCH] Very minor changes of some JS files --- app/assets/javascripts/app/app.js | 4 ++-- .../javascripts/app/collections/comments.js | 16 ++++++++-------- app/assets/javascripts/app/collections/posts.js | 1 - .../javascripts/app/collections/reshares.js | 1 - app/assets/javascripts/app/models.js | 3 --- .../javascripts/app/models/aspect_membership.js | 1 - app/assets/javascripts/app/models/comment.js | 1 - .../javascripts/app/models/post/interactions.js | 9 ++++++--- .../javascripts/app/models/status_message.js | 1 - .../javascripts/app/models/stream_aspects.js | 3 +-- app/assets/javascripts/app/pages/contacts.js | 1 - app/assets/javascripts/app/pages/profile.js | 1 - .../javascripts/app/pages/single-post-viewer.js | 3 +-- app/assets/javascripts/app/router.js | 8 +++++--- app/assets/javascripts/app/views.js | 1 - app/assets/javascripts/browser_detection.js | 1 - app/assets/javascripts/contact-list.js | 1 - app/assets/javascripts/diaspora.js | 4 ++-- app/assets/javascripts/mentions.js | 1 - app/assets/javascripts/mobile/mobile_comments.js | 6 ++++++ app/assets/javascripts/mobile/profile_aspects.js | 1 - app/assets/javascripts/widgets/flash-messages.js | 1 - .../javascripts/widgets/infinite-scroll.js | 7 +++---- app/assets/javascripts/widgets/lightbox.js | 1 - .../app/helpers/date_formatter_spec.js | 1 - spec/javascripts/bookmarklet-spec.js | 1 - spec/javascripts/view-spec.js | 8 ++++---- 27 files changed, 38 insertions(+), 49 deletions(-) diff --git a/app/assets/javascripts/app/app.js b/app/assets/javascripts/app/app.js index d623e2eda..24b35469d 100644 --- a/app/assets/javascripts/app/app.js +++ b/app/assets/javascripts/app/app.js @@ -63,7 +63,7 @@ var app = { }, parsePreload : function(prop) { - if(!app.hasPreload(prop)) { return } + if(!app.hasPreload(prop)) { return; } var preload = window.gon.preloads[prop]; delete window.gon.preloads[prop]; //prevent dirty state across navigates @@ -112,7 +112,7 @@ var app = { /* mixpanel wrapper function */ instrument : function(type, name, object, callback) { - if(!window.mixpanel) { return } + if(!window.mixpanel) { return; } window.mixpanel[type](name, object, callback); }, diff --git a/app/assets/javascripts/app/collections/comments.js b/app/assets/javascripts/app/collections/comments.js index f096363e0..2a80a28cd 100644 --- a/app/assets/javascripts/app/collections/comments.js +++ b/app/assets/javascripts/app/collections/comments.js @@ -2,22 +2,22 @@ app.collections.Comments = Backbone.Collection.extend({ model: app.models.Comment, - url: function() { return _.result(this.post, 'url') + '/comments'; }, + url: function() { + return _.result(this.post, "url") + "/comments"; + }, initialize : function(models, options) { this.post = options.post; }, - make : function(text){ - var self = this; - - var comment = new app.models.Comment({text: text }); + make : function(text) { + var comment = new app.models.Comment({ "text": text }); var deferred = comment.save({}, { - url: '/posts/'+this.post.id+'/comments', + 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: this.post }); + this.add(comment); } }); diff --git a/app/assets/javascripts/app/collections/posts.js b/app/assets/javascripts/app/collections/posts.js index fc5fe1bbe..d05ed6bbc 100644 --- a/app/assets/javascripts/app/collections/posts.js +++ b/app/assets/javascripts/app/collections/posts.js @@ -5,4 +5,3 @@ app.collections.Posts = Backbone.Collection.extend({ url : "/posts" }); // @license-end - diff --git a/app/assets/javascripts/app/collections/reshares.js b/app/assets/javascripts/app/collections/reshares.js index 28ce59c24..1aee51053 100644 --- a/app/assets/javascripts/app/collections/reshares.js +++ b/app/assets/javascripts/app/collections/reshares.js @@ -5,4 +5,3 @@ app.collections.Reshares = Backbone.Collection.extend({ url : "/reshares" }); // @license-end - diff --git a/app/assets/javascripts/app/models.js b/app/assets/javascripts/app/models.js index 286e990c6..87dfe9843 100644 --- a/app/assets/javascripts/app/models.js +++ b/app/assets/javascripts/app/models.js @@ -5,7 +5,6 @@ // Requires: // this = model with "created_at" attribute app.models.formatDateMixin = { - timeOf: function(field) { return app.helpers.dateFormatter.parse(this.get(field)) / 1000; }, @@ -13,7 +12,5 @@ app.models.formatDateMixin = { createdAt: function() { return this.timeOf("created_at"); } - }; // @license-end - diff --git a/app/assets/javascripts/app/models/aspect_membership.js b/app/assets/javascripts/app/models/aspect_membership.js index ddb503702..a4bd99b97 100644 --- a/app/assets/javascripts/app/models/aspect_membership.js +++ b/app/assets/javascripts/app/models/aspect_membership.js @@ -8,4 +8,3 @@ app.models.AspectMembership = Backbone.Model.extend({ urlRoot: "/aspect_memberships" }); // @license-end - diff --git a/app/assets/javascripts/app/models/comment.js b/app/assets/javascripts/app/models/comment.js index f2778f718..d382b731f 100644 --- a/app/assets/javascripts/app/models/comment.js +++ b/app/assets/javascripts/app/models/comment.js @@ -4,4 +4,3 @@ app.models.Comment = Backbone.Model.extend({ urlRoot: "/comments" }); // @license-end - diff --git a/app/assets/javascripts/app/models/post/interactions.js b/app/assets/javascripts/app/models/post/interactions.js index d992440f7..3913b1fd0 100644 --- a/app/assets/javascripts/app/models/post/interactions.js +++ b/app/assets/javascripts/app/models/post/interactions.js @@ -32,7 +32,7 @@ app.models.Post.Interactions = Backbone.Model.extend({ }, 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(){ @@ -44,12 +44,15 @@ app.models.Post.Interactions = Backbone.Model.extend({ }, 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() { diff --git a/app/assets/javascripts/app/models/status_message.js b/app/assets/javascripts/app/models/status_message.js index f8469662a..d233b09eb 100644 --- a/app/assets/javascripts/app/models/status_message.js +++ b/app/assets/javascripts/app/models/status_message.js @@ -21,4 +21,3 @@ app.models.StatusMessage = app.models.Post.extend({ } }); // @license-end - diff --git a/app/assets/javascripts/app/models/stream_aspects.js b/app/assets/javascripts/app/models/stream_aspects.js index e64d3ea5b..319fe106c 100644 --- a/app/assets/javascripts/app/models/stream_aspects.js +++ b/app/assets/javascripts/app/models/stream_aspects.js @@ -17,7 +17,7 @@ app.models.StreamAspects = app.models.Stream.extend({ }, fetch: function() { - if(this.isFetching()){ return false } + if(this.isFetching()) { return false; } var url = this.url(); var ids = this.aspects_ids; this.deferred = this.items.fetch(this._fetchOpts({url : url, data : { 'a_ids': ids }})) @@ -32,4 +32,3 @@ app.models.StreamAspects = app.models.Stream.extend({ } }); // @license-end - diff --git a/app/assets/javascripts/app/pages/contacts.js b/app/assets/javascripts/app/pages/contacts.js index b3675af6a..9b26efcae 100644 --- a/app/assets/javascripts/app/pages/contacts.js +++ b/app/assets/javascripts/app/pages/contacts.js @@ -98,4 +98,3 @@ app.pages.Contacts = Backbone.View.extend({ } }); // @license-end - diff --git a/app/assets/javascripts/app/pages/profile.js b/app/assets/javascripts/app/pages/profile.js index f9f24da73..3f9bb030a 100644 --- a/app/assets/javascripts/app/pages/profile.js +++ b/app/assets/javascripts/app/pages/profile.js @@ -127,4 +127,3 @@ app.pages.Profile = app.views.Base.extend({ } }); // @license-end - diff --git a/app/assets/javascripts/app/pages/single-post-viewer.js b/app/assets/javascripts/app/pages/single-post-viewer.js index 0eb0cc0d8..21be997f5 100644 --- a/app/assets/javascripts/app/pages/single-post-viewer.js +++ b/app/assets/javascripts/app/pages/single-post-viewer.js @@ -37,7 +37,6 @@ app.pages.SinglePostViewer = app.views.Base.extend({ //... and converts html to plain text document.title = $('
').html(html_title).text(); } - }, - + } }); // @license-end diff --git a/app/assets/javascripts/app/router.js b/app/assets/javascripts/app/router.js index 0a9958bcf..eb254d1c2 100644 --- a/app/assets/javascripts/app/router.js +++ b/app/assets/javascripts/app/router.js @@ -170,9 +170,11 @@ app.Router = Backbone.Router.extend({ }, profile: function() { - this.renderPage(function() { return new app.pages.Profile({ - el: $("body > #profile_container") - }); }); + this.renderPage(function() { + return new app.pages.Profile({ + el: $("body > #profile_container") + }); + }); } }); // @license-end diff --git a/app/assets/javascripts/app/views.js b/app/assets/javascripts/app/views.js index 55ec8fffc..043800d08 100644 --- a/app/assets/javascripts/app/views.js +++ b/app/assets/javascripts/app/views.js @@ -150,7 +150,6 @@ app.views.Base = Backbone.View.extend({ }); app.views.StaticContentView = app.views.Base.extend({ - initialize : function(options) { this.templateName = options.templateName; this.data = options.data; diff --git a/app/assets/javascripts/browser_detection.js b/app/assets/javascripts/browser_detection.js index 6a8e5adab..3552deadd 100644 --- a/app/assets/javascripts/browser_detection.js +++ b/app/assets/javascripts/browser_detection.js @@ -6,4 +6,3 @@ jQuery.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase()); jQuery.browser.opera = /opera/.test(navigator.userAgent.toLowerCase()); jQuery.browser.msie = /msie/.test(navigator.userAgent.toLowerCase()); // @license-end - diff --git a/app/assets/javascripts/contact-list.js b/app/assets/javascripts/contact-list.js index 0e8bda50e..2c56167ba 100644 --- a/app/assets/javascripts/contact-list.js +++ b/app/assets/javascripts/contact-list.js @@ -25,4 +25,3 @@ var List = { } }; // @license-end - diff --git a/app/assets/javascripts/diaspora.js b/app/assets/javascripts/diaspora.js index 054905786..73ff43694 100644 --- a/app/assets/javascripts/diaspora.js +++ b/app/assets/javascripts/diaspora.js @@ -49,7 +49,7 @@ $.extend(Diaspora.Widgets[Widget].prototype, Diaspora.EventBroker.extend(Diaspora.BaseWidget)); var widget = new Diaspora.Widgets[Widget](), - args = Array.prototype.slice.call(arguments, 1); + args = Array.prototype.slice.call(arguments, 1); widget.publish("widget/ready", args); @@ -87,7 +87,7 @@ Diaspora.page = new Page(); } - if(!$.mobile)//why does this need this? + if(!$.mobile) // why does this need this? $.extend(Diaspora.page, new Diaspora.BasePage($(document.body))); Diaspora.page.publish("page/ready", [$(document.body)]); }; diff --git a/app/assets/javascripts/mentions.js b/app/assets/javascripts/mentions.js index 33058ae67..f805b97fa 100644 --- a/app/assets/javascripts/mentions.js +++ b/app/assets/javascripts/mentions.js @@ -46,4 +46,3 @@ var Mentions = { } }; // @license-end - diff --git a/app/assets/javascripts/mobile/mobile_comments.js b/app/assets/javascripts/mobile/mobile_comments.js index ea1402819..2dedaf9d5 100644 --- a/app/assets/javascripts/mobile/mobile_comments.js +++ b/app/assets/javascripts/mobile/mobile_comments.js @@ -26,6 +26,7 @@ $(document).ready(function() { showComments(toggleReactionsLink); } } + function hideComments(toggleReactionsLink) { var bottomBar = toggleReactionsLink.closest(".bottom_bar").first(), commentsContainer = commentsContainerLazy(bottomBar), @@ -33,6 +34,7 @@ $(document).ready(function() { existingCommentsContainer.hide(); toggleReactionsLink.removeClass("active"); } + function showComments(toggleReactionsLink) { var bottomBar = toggleReactionsLink.closest(".bottom_bar").first(), commentsContainer = commentsContainerLazy(bottomBar), @@ -44,12 +46,14 @@ $(document).ready(function() { showUnloadedComments(toggleReactionsLink, bottomBar, commentActionLink); } } + function showLoadedComments(toggleReactionsLink, existingCommentsContainer, commentActionLink) { existingCommentsContainer.show(); showCommentBox(commentActionLink); toggleReactionsLink.addClass("active"); existingCommentsContainer.find("time.timeago").timeago(); } + function showUnloadedComments(toggleReactionsLink, bottomBar, commentActionLink) { var commentsContainer = commentsContainerLazy(bottomBar); $.ajax({ @@ -62,6 +66,7 @@ $(document).ready(function() { } }); } + function commentsContainerLazy(bottomBar) { return function() { return bottomBar.find(".comment_container").first(); @@ -140,6 +145,7 @@ $(document).ready(function() { return parseInt(match) + 1; })); } + // Fix for no reactions function updateReactionCount(bottomBar) { var toggleReactionsLink = bottomBar.find(".show_comments").first(); diff --git a/app/assets/javascripts/mobile/profile_aspects.js b/app/assets/javascripts/mobile/profile_aspects.js index 2c664f045..899a60fe9 100644 --- a/app/assets/javascripts/mobile/profile_aspects.js +++ b/app/assets/javascripts/mobile/profile_aspects.js @@ -81,4 +81,3 @@ $(document).ready(function(){ $(this).change(profileAspectDropDown_onchange); }); }); - diff --git a/app/assets/javascripts/widgets/flash-messages.js b/app/assets/javascripts/widgets/flash-messages.js index 142efce74..4cb0c9382 100644 --- a/app/assets/javascripts/widgets/flash-messages.js +++ b/app/assets/javascripts/widgets/flash-messages.js @@ -36,4 +36,3 @@ Diaspora.Widgets.FlashMessages = FlashMessages; })(); // @license-end - diff --git a/app/assets/javascripts/widgets/infinite-scroll.js b/app/assets/javascripts/widgets/infinite-scroll.js index 4e0c745b9..3d81082f8 100644 --- a/app/assets/javascripts/widgets/infinite-scroll.js +++ b/app/assets/javascripts/widgets/infinite-scroll.js @@ -1,9 +1,9 @@ // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later /* Copyright (c) 2010-2011, Diaspora Inc. This file is -* licensed under the Affero General Public License version 3 or later. See -* the COPYRIGHT file. -*/ + * licensed under the Affero General Public License version 3 or later. See + * the COPYRIGHT file. + */ (function() { var InfiniteScroll = function() { @@ -59,4 +59,3 @@ Diaspora.Widgets.InfiniteScroll = InfiniteScroll; })(); // @license-end - diff --git a/app/assets/javascripts/widgets/lightbox.js b/app/assets/javascripts/widgets/lightbox.js index 461be1d0e..890a55ff8 100644 --- a/app/assets/javascripts/widgets/lightbox.js +++ b/app/assets/javascripts/widgets/lightbox.js @@ -190,4 +190,3 @@ jQuery.fn.center = (function() { Diaspora.Widgets.Lightbox = Lightbox; })(); // @license-end - diff --git a/spec/javascripts/app/helpers/date_formatter_spec.js b/spec/javascripts/app/helpers/date_formatter_spec.js index 141cdbd6e..7343aea9d 100644 --- a/spec/javascripts/app/helpers/date_formatter_spec.js +++ b/spec/javascripts/app/helpers/date_formatter_spec.js @@ -1,5 +1,4 @@ describe("app.helpers.dateFormatter", function(){ - beforeEach(function(){ this.statusMessage = factory.post(); this.formatter = app.helpers.dateFormatter; diff --git a/spec/javascripts/bookmarklet-spec.js b/spec/javascripts/bookmarklet-spec.js index 4964e975e..d12fd6e47 100644 --- a/spec/javascripts/bookmarklet-spec.js +++ b/spec/javascripts/bookmarklet-spec.js @@ -1,4 +1,3 @@ - describe("bookmarklet", function(){ var fakeUrl = "http://pod.example.com/bookmarklet"; diff --git a/spec/javascripts/view-spec.js b/spec/javascripts/view-spec.js index 5542b8fae..b9fba7ee9 100644 --- a/spec/javascripts/view-spec.js +++ b/spec/javascripts/view-spec.js @@ -1,7 +1,7 @@ -/* Copyright (c) 2010-2011, Diaspora Inc. This file is -* licensed under the Affero General Public License version 3 or later. See -* the COPYRIGHT file. -*/ +/* Copyright (c) 2010-2011, Diaspora Inc. This file is + * licensed under the Affero General Public License version 3 or later. See + * the COPYRIGHT file. + */ describe("View", function() { it("is the object that helps the UI", function() {