diff --git a/app/assets/javascripts/app/app.js b/app/assets/javascripts/app/app.js index c353a3c9998d312484bb49e6e8f0009f0815d247..d0a6a5158c90fad5a497af6ab73b251f34908dcb 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 dd8ee1b5d2297e961f662cf7f7d44cab0c43355d..dc3c0410bd506e45a16be286ac37f7c57ed0e631 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 ce9fca6f540d516aa4e5ac9f49d14efa1bbeb315..1e284274be960a7735a845ceac8e3b20dfc60e7f 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 34f4e82519e42f841c0ce21db4c72da3546fcf63..f096363e0537e38e26e94c60cf3d6d94cc8cd016 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 d34a92270da75ee471b18a66ffd11750d4400153..76168237be97f13006c799fa395cc74119707a7a 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 da8c636a91c69740f43617f88794ada50cac5d72..978858304b12a5b6a2f1b70475fe462db59da427 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 1226d94c7d8073535453705b75ad87bad72f68f6..395e55f6528e5b5e7df92c2a28d1a80b2161ba82 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 0b59ba93b47a939fbb75edefa4aedb0feadf2889..c6a9254b64079444065f2fc82028d7fbd7fdfd81 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 += "</a>"; - 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 += "</a>"; - 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 50efeeb64eac0e27f046629dd17ef3496bd65fb4..6f18152291096a8fff3961fb75d51ad17214b71d 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 be410c9d32589754c71c4673f73174cc8ef2d14f..c09df1798ce8386ecff797e95cad3a31e06aab54 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 '<img src="' + data.url + '" width="' + data.width + '" height="' + data.height + '" />' + return '<img src="' + data.url + '" width="' + data.width + '" height="' + data.height + '" />'; } 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 d2aa388dbad54077e4bfcd5e6e0f8a8360887ae9..73d9de4670d5ddc15ac8768e330bac5cea9c53e4 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 3c188188c70cd7e56da8799c585c89151f75e2f7..b9e56f16968620488b0f0790ed2fdd5d2649ce37 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 0039e351863cf7b7b38e6ea382da3b4b1b77926e..59c54314597655da71144395f17f08b75f291859 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 9fd9de3dfd3aeab0136854335e04ddcce1a14a8e..a236f23844f8d3748077139905b9621eb953f97a 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 317b4adc66267193bbc5fd6b7ce92bc8b2aba53d..f8469662af01ef98c1d7c9e1893e9a0aaabe90b7 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 54a51a7474545e46d454ecf839c86a9d21924de1..f66cc068676e2f975d26f4559ebd834674d2f81f 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 a0115887d698071c9df6f426b4fcb4da8e89bc5d..e64d3ea5b3a3911074682a959e02228b6559cb4e 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 98dc67c01b253d1eb78e4a0a08e7a6c2f8c06a71..df8974ff05a03e8bf2e1377d139a8581c44d778b 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 b5af389b3d5c263f3a7497246b25b4f76b1e0eae..c0b5f6bf9528d42d685102c09407a9437c11b693 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 76398707cd5105fa2e1a61bab7c65fa1cf1499fa..4e5e6d36cef85de0aed1e764579c147b699c9a41 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 a677e54d4e1ad4122a12a0efa0966b596bca26a6..ef7f8253314097c2202d15558fd4e563382f289a 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 4d986ee9d9faf5d63218bf29ba88bfa113c142aa..3fba4865c45692f95ba76942a306f4d5c02fb119 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 61f671645a0c876437549c20f037221afad046ce..6af4d41cc3d0987b53afdafe49f088b4ae2c45aa 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 32c349e8bdc51d59b329eca2a4490cecf7c06532..c694f1cace138b32a78f096f55282f91c229a315 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 f99bd7f664415f3fc5e5aae7e55dcf68e08be3ad..ca9965c66b0fdd9d63304d5b5198a0bfee7d9003 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 71c6411413bdd4ca421d4feee62372fda877bfe5..13816e34e88c144c61c07016fde1504fd38922d0 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 200a118305c7fa1b9daf04b8b34ebe49584dcc8b..938469bbb04c98ec893ec49b31b3432f0705e692 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 fa93966a00c715ac569bb3145a2a253a8d926711..c2c586adf00ca5040d266a5e77ea2f5be07b95f1 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 e4497b18ab923c88f8b5578ad2596020b6a1b1f6..b113e2ce6ec946179923863b4c8523ccfca13321 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 59e493ee601277f18907e650bec9986769f37307..8e755a7f433a406eef9379e403856798a4566945 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 b85be03eddfa9241646630c13ed309b5c178d6e6..a672645dda6c2bfdb9825eb75698652b9abfc462 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 e2b8e939fd98722f8ee49501f04d7dfead36007e..d9a5874000826bf1cf37f2df020c14e9a1d57fee 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 bbba5766e28df07c17ae0669b033eb27f813d8a8..2870f6446a53a66a75b4a39b7141beaad4423325 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 195b468e1d1a39c26d95dfac5ad7949b07bf1ff1..726055bb7acf3a7b3b814188c6ab693aae396c56 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 302d6c335dce12d37cf178a621839c70e923fc4f..b8218fed974a10bb51818e302c3ce9431cc9751a 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 79443d1ec6fe171a688da15f14cdb12a4399d4c3..86143412e3b25719702f96ebed398d1934788d08 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 eee0097ec0c3b893a97df45e28822d75d1b09317..4aa89f199d24afd5649eeb4af97973337db4a11f 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 07f4d431d3768d26c4b4e447e713e4694c4d5dac..497a8e83a87507ec8ca0a8a441312c290a9c979d 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 67f83f3b57b89bf79a13857272613db810b8cba8..967b72f9f6ed8ee4e845cddf33ed69cb59648a79 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 19fa85435a3a4a795301b7aafcdc3bcef11d9f7f..b8c4a8661a0f766b7d4da926b36dc9f467d9022e 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 9091c8bbeddfda93d591ec815f233fa7158e10e5..0586f6df57e596be3b16e90f178018513dd60825 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 3fe47f3e8beaa5dd20343bb46eda42ff84f1fd83..da34f8bd8790e90dbd842de61d3f894c6d5ac07f 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 ca3058279ef94d443047b75d1c6ff5b7f730646d..940b5a4014ccf3b5b331794d1f1ff6ff9d33c199 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 2f770c1b976728609bfe65f75159b8e3921756cc..3475bc54597502f535b31e41a5f85533142d2086 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 611b74f14d35af1c54405282688aec380a1433aa..838fd896d93fc11d4918b11902ded80b47aa6bb7 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 fceb73af8ed33ec269af566fe6d701cd60af99b9..ef01bd769fb2b65496e8123a3860ba934924c86e 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 ea469b90f385f6e12d968931e6c75215747dcb6e..de5a979006bf06416c5718b418f3c66fe545070d 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 456813851eaab77991dfbd6786048eefe883dc2a..e297ae0f6d1e9f551e0797f2ddb322e95e02fb4f 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 6354b6bd21dceb37da25dc3b922e021a1832d990..9e64978e93e76ad4d87fa59b1cac3cb3253edbdd 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 9a7b59a9358e2a3a6940561e81003461a2e4535b..e5517b768e49e917988106b40673fe77ec90de24 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 a833bd035d56ed9c978d4f44f69dc1d250e2d08b..9ce4e6a908a90e7cb46d66971f4326c6e4bd61df 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 dd569728e8624601d73fa4e86ac374861774da73..bde326774ee22bebff488912907d92838fdb3c0e 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 ef631c1f4db23a06c2000190be9407b002fa7bc9..b2b91922b4229d34ec903e5768acc42676316ed3 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 46108f8de05145783c804a107d1f92321881e6a7..226788bfe945d4723c8c99870cbb70399c5ca2a5 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 ee21be3a6386e49ab98b2fb02db559eab21f413f..55407519406f4eade9dce8a766a1f47b093b3712 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 0e33217f0f480ded61c662b32048aa5697cf1645..e6146781a1272b675c808724b66c728d0cf82486 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 e45c99b31f782fae7793f7873a681285ae082652..ae1bae9b06ddf1a44cd9fc3e1588bd80b9366651 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 e5f396fd15ac4d16bd24654775e8c7e252481119..2840c1d318ca0744b23e82a537ae7bbca2b1d248 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 76f6498e9c8dd178b6078d3a01636a8efe469438..0e8c3ddf55682ebcb6be4aca92fab1a53fd56e02 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 2928884036384a3fe78e4cf743a109c08ff0f4d1..b23f5ae7ac80bb0b8c2172692ac5a73439d2b81e 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 b3b4c646cd2bffea9a703dda32040de60afe5ad4..d776d35e6b3959e06720f4a54b725443bbc3ca00 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 9d317a108ec237b191c30bc369b05bccc4481bec..141cdbd6ec1785083edeccafd06e39b126be673a 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 0e01004bf584a7d0285c8243cad9ea5e1c82c8e7..b00ee315598ffb1cb642b271fa06b19f0dafd46f 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 = $("<div>").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 = $("<div>").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(/<a/)).toBeNull(); expect(formattedText).toContain('Chris Smith'); }); @@ -100,7 +100,7 @@ describe("app.helpers.textFormatter", function(){ var linkElement = wrapper.find("a[href*='" + link + "']"); expect(linkElement.text()).toContain(link); expect(linkElement.attr("target")).toContain("_blank"); - }) + }); }); context("symbol conversion", function() { @@ -200,7 +200,7 @@ describe("app.helpers.textFormatter", function(){ context("misc breakage and/or other issues with weird urls", function(){ it("doesn't crash Firefox", function() { - var content = "antifaschistisch-feministische ://" + var content = "antifaschistisch-feministische ://"; var parsed = this.formatter(content); expect(parsed).toContain(content); }); @@ -221,7 +221,7 @@ describe("app.helpers.textFormatter", function(){ context("percent-encoded input url", function() { beforeEach(function() { - this.input = "http://www.soilandhealth.org/01aglibrary/010175.tree%20crops.pdf" // #4507 + this.input = "http://www.soilandhealth.org/01aglibrary/010175.tree%20crops.pdf"; // #4507 this.correctHref = 'href="'+this.input+'"'; }); @@ -266,4 +266,4 @@ describe("app.helpers.textFormatter", function(){ } }); }); -}) +}); diff --git a/spec/javascripts/app/models/post/interacations_spec.js b/spec/javascripts/app/models/post/interacations_spec.js index a4e60172776ae7215d24cfb71a8d04fb7158bd8b..017edbeccdab2f1cc07142e43bbd16c8607b0d0c 100644 --- a/spec/javascripts/app/models/post/interacations_spec.js +++ b/spec/javascripts/app/models/post/interacations_spec.js @@ -1,16 +1,16 @@ describe("app.models.Post.Interactions", function(){ beforeEach(function(){ this.interactions = factory.post().interactions; - this.author = factory.author({guid: "loggedInAsARockstar"}) - loginAs({guid: "loggedInAsARockstar"}) + this.author = factory.author({guid: "loggedInAsARockstar"}); + loginAs({guid: "loggedInAsARockstar"}); - this.userLike = new app.models.Like({author : this.author}) + this.userLike = new app.models.Like({author : this.author}); }); describe("toggleLike", function(){ it("calls unliked when the user_like exists", function(){ spyOn(this.interactions, "unlike").and.returnValue(true); - this.interactions.likes.add(this.userLike) + this.interactions.likes.add(this.userLike); this.interactions.toggleLike(); expect(this.interactions.unlike).toHaveBeenCalled(); @@ -34,7 +34,7 @@ describe("app.models.Post.Interactions", function(){ describe("unlike", function(){ it("calls destroy on the likes collection", function(){ - this.interactions.likes.add(this.userLike) + this.interactions.likes.add(this.userLike); this.interactions.unlike(); expect(this.interactions.likes.length).toEqual(0); diff --git a/spec/javascripts/app/models/post_spec.js b/spec/javascripts/app/models/post_spec.js index bdcde53a83557e6791e6a58d0221bf4608c5b71d..b644e26be0d2bdd94e2acd5761d0c6bc4eccc3c3 100644 --- a/spec/javascripts/app/models/post_spec.js +++ b/spec/javascripts/app/models/post_spec.js @@ -1,31 +1,31 @@ describe("app.models.Post", function() { beforeEach(function(){ this.post = new app.models.Post(); - }) + }); describe("headline and body", function(){ describe("headline", function(){ beforeEach(function(){ - this.post.set({text :" yes "}) - }) + this.post.set({text :" yes "}); + }); it("the headline is the entirety of the post", function(){ - expect(this.post.headline()).toBe("yes") - }) + expect(this.post.headline()).toBe("yes"); + }); it("takes up until the new line", function(){ - this.post.set({text : "love\nis avery powerful force"}) - expect(this.post.headline()).toBe("love") - }) - }) + this.post.set({text : "love\nis avery powerful force"}); + expect(this.post.headline()).toBe("love"); + }); + }); describe("body", function(){ it("takes after the new line", function(){ - this.post.set({text : "Inflamatory Title\nwith text that substantiates a less absolutist view of the title."}) - expect(this.post.body()).toBe("with text that substantiates a less absolutist view of the title.") - }) - }) - }) + this.post.set({text : "Inflamatory Title\nwith text that substantiates a less absolutist view of the title."}); + expect(this.post.body()).toBe("with text that substantiates a less absolutist view of the title."); + }); + }); + }); describe("createdAt", function() { it("returns the post's created_at as an integer", function() { @@ -39,25 +39,25 @@ describe("app.models.Post", function() { describe("hasPhotos", function(){ it('returns true if the model has more than one photo', function(){ - this.post.set({photos : [1,2]}) - expect(this.post.hasPhotos()).toBeTruthy() - }) + this.post.set({photos : [1,2]}); + expect(this.post.hasPhotos()).toBeTruthy(); + }); it('returns false if the model does not have any photos', function(){ - this.post.set({photos : []}) - expect(this.post.hasPhotos()).toBeFalsy() - }) + this.post.set({photos : []}); + expect(this.post.hasPhotos()).toBeFalsy(); + }); }); describe("hasText", function(){ it('returns true if the model has text', function(){ - this.post.set({text : "hella"}) - expect(this.post.hasText()).toBeTruthy() - }) + this.post.set({text : "hella"}); + expect(this.post.hasText()).toBeTruthy(); + }); it('returns false if the model does not have text', function(){ - this.post.set({text : " "}) - expect(this.post.hasText()).toBeFalsy() - }) + this.post.set({text : " "}); + expect(this.post.hasText()).toBeFalsy(); + }); }); }); diff --git a/spec/javascripts/app/models/reshare_spec.js b/spec/javascripts/app/models/reshare_spec.js index 04fc949b10d710c0e5d8f7cd1550e45f27c27fe6..e93c34e00c224149afed166206bb04db166f08b3 100644 --- a/spec/javascripts/app/models/reshare_spec.js +++ b/spec/javascripts/app/models/reshare_spec.js @@ -1,27 +1,27 @@ describe("app.models.Reshare", function(){ beforeEach(function(){ - this.reshare = new app.models.Reshare({root: {a:"namaste", be : "aloha", see : "community"}}) + this.reshare = new app.models.Reshare({root: {a:"namaste", be : "aloha", see : "community"}}); }); describe("rootPost", function(){ it("should be the root attrs", function(){ - expect(this.reshare.rootPost().get("be")).toBe("aloha") + expect(this.reshare.rootPost().get("be")).toBe("aloha"); }); it("should return a post", function(){ - expect(this.reshare.rootPost() instanceof app.models.Post).toBeTruthy() + expect(this.reshare.rootPost() instanceof app.models.Post).toBeTruthy(); }); it("does not create a new object every time", function(){ - expect(this.reshare.rootPost()).toBe(this.reshare.rootPost()) + expect(this.reshare.rootPost()).toBe(this.reshare.rootPost()); }); }); describe(".reshare", function(){ it("reshares the root post", function(){ - spyOn(this.reshare.rootPost(), "reshare") - this.reshare.reshare() - expect(this.reshare.rootPost().reshare).toHaveBeenCalled() + spyOn(this.reshare.rootPost(), "reshare"); + this.reshare.reshare(); + expect(this.reshare.rootPost().reshare).toHaveBeenCalled(); }); it("returns something", function() { diff --git a/spec/javascripts/app/models/status_message_spec.js b/spec/javascripts/app/models/status_message_spec.js index ad8c93a31ec1bbad84d1fd9171c73bd8dda1a98f..c801560748fe168f382afbb75fa2059161d46acb 100644 --- a/spec/javascripts/app/models/status_message_spec.js +++ b/spec/javascripts/app/models/status_message_spec.js @@ -1,12 +1,12 @@ describe("app.models.StatusMessage", function(){ describe("#url", function(){ it("is /status_messages when its new", function(){ - var post = new app.models.StatusMessage() - expect(post.url()).toBe("/status_messages") - }) + var post = new app.models.StatusMessage(); + expect(post.url()).toBe("/status_messages"); + }); it("is /posts/id when it has an id", function(){ - expect(new app.models.StatusMessage({id : 5}).url()).toBe("/posts/5") - }) - }) -}) \ No newline at end of file + expect(new app.models.StatusMessage({id : 5}).url()).toBe("/posts/5"); + }); + }); +}); diff --git a/spec/javascripts/app/models/user_spec.js b/spec/javascripts/app/models/user_spec.js index 6870a07dfd241a98b39b73fdb1f72fa59d40c1cf..621b35a368056a7935094b2231b415ddbe1320d7 100644 --- a/spec/javascripts/app/models/user_spec.js +++ b/spec/javascripts/app/models/user_spec.js @@ -1,6 +1,6 @@ describe("app.models.User", function(){ beforeEach(function(){ - this.user = new app.models.User({}) + this.user = new app.models.User({}); }); describe("authenticated", function(){ @@ -9,17 +9,16 @@ describe("app.models.User", function(){ }); it('should be true if ID is set', function(){ - this.user.set({id : 1}) + this.user.set({id : 1}); expect(this.user.authenticated()).toBeTruthy(); }); }); describe("isServiceConnected", function(){ it("checks to see if the sent provider name is a configured service", function(){ - this.user.set({configured_services : ["facebook"]}) - expect(this.user.isServiceConfigured("facebook")).toBeTruthy() - expect(this.user.isServiceConfigured("tumblr")).toBeFalsy() + this.user.set({configured_services : ["facebook"]}); + expect(this.user.isServiceConfigured("facebook")).toBeTruthy(); + expect(this.user.isServiceConfigured("tumblr")).toBeFalsy(); }); }); }); - diff --git a/spec/javascripts/app/views/aspects_list_view_spec.js b/spec/javascripts/app/views/aspects_list_view_spec.js index 6c18e349021b723f2389f52f1a50ff6e37fe2bbd..72d029d4c49c04786963fa301095c7374e84eba7 100644 --- a/spec/javascripts/app/views/aspects_list_view_spec.js +++ b/spec/javascripts/app/views/aspects_list_view_spec.js @@ -25,7 +25,7 @@ describe("app.views.AspectsList", function(){ it('should show all the aspects', function(){ var aspect_selectors = this.view.$('.icons-check_yes_ok + a.selectable'); - expect(aspect_selectors.length).toBe(3) + expect(aspect_selectors.length).toBe(3); expect(aspect_selectors[0].text).toMatch('Work'); expect(aspect_selectors[1].text).toMatch('Friends'); expect(aspect_selectors[2].text).toMatch('Acquaintances'); diff --git a/spec/javascripts/app/views/comment_stream_view_spec.js b/spec/javascripts/app/views/comment_stream_view_spec.js index 816ce35a214a0fce233e44fa05573a2aaf473c43..8ed0592c40f4e0d88388d7ddfae68eb2b02bd3e8 100644 --- a/spec/javascripts/app/views/comment_stream_view_spec.js +++ b/spec/javascripts/app/views/comment_stream_view_spec.js @@ -15,17 +15,17 @@ describe("app.views.CommentStream", function(){ describe("postRenderTemplate", function(){ it("applies infield labels", function(){ - spyOn($.fn, "placeholder") - this.view.postRenderTemplate() - expect($.fn.placeholder).toHaveBeenCalled() - expect($.fn.placeholder.calls.mostRecent().object.selector).toBe("textarea") + spyOn($.fn, "placeholder"); + this.view.postRenderTemplate(); + expect($.fn.placeholder).toHaveBeenCalled(); + expect($.fn.placeholder.calls.mostRecent().object.selector).toBe("textarea"); }); it("autoResizes the new comment textarea", function(){ - spyOn($.fn, "autoResize") - this.view.postRenderTemplate() - expect($.fn.autoResize).toHaveBeenCalled() - expect($.fn.autoResize.calls.mostRecent().object.selector).toBe("textarea") + spyOn($.fn, "autoResize"); + this.view.postRenderTemplate(); + expect($.fn.autoResize).toHaveBeenCalled(); + expect($.fn.autoResize.calls.mostRecent().object.selector).toBe("textarea"); }); }); @@ -108,7 +108,7 @@ describe("app.views.CommentStream", function(){ it("should not submit the form when enter key is pressed", function(){ this.view.render(); - var form = this.view.$("form") + var form = this.view.$("form"); form.submit(submitCallback); var e = $.Event("keydown", { keyCode: 13 }); diff --git a/spec/javascripts/app/views/comment_view_spec.js b/spec/javascripts/app/views/comment_view_spec.js index 4ba3f708b4e8170967f56279992c099f3998847b..fc5a633cf3f7517cd0ba1df375881fcfd5e3f558 100644 --- a/spec/javascripts/app/views/comment_view_spec.js +++ b/spec/javascripts/app/views/comment_view_spec.js @@ -1,75 +1,75 @@ describe("app.views.Comment", function(){ beforeEach(function(){ - this.post = factory.post({author : {diaspora_id : "xxx@xxx.xxx"}}) - this.comment = factory.comment({parent : this.post.toJSON()}) - this.view = new app.views.Comment({model : this.comment}) - }) + this.post = factory.post({author : {diaspora_id : "xxx@xxx.xxx"}}); + this.comment = factory.comment({parent : this.post.toJSON()}); + this.view = new app.views.Comment({model : this.comment}); + }); describe("render", function(){ it("has a delete link if the author is the current user", function(){ - loginAs(this.comment.get("author")) - expect(this.view.render().$('.delete').length).toBe(1) - }) + loginAs(this.comment.get("author")); + expect(this.view.render().$('.delete').length).toBe(1); + }); it("doesn't have a delete link if the author is not the current user", function(){ - loginAs(factory.author({diaspora_id : "notbob@bob.com"})) - expect(this.view.render().$('.delete').length).toBe(0) - }) + loginAs(factory.author({diaspora_id : "notbob@bob.com"})); + expect(this.view.render().$('.delete').length).toBe(0); + }); it("doesn't have a delete link if the user is logged out", function(){ - logout() - expect(this.view.render().$('.delete').length).toBe(0) - }) - }) + logout(); + expect(this.view.render().$('.delete').length).toBe(0); + }); + }); describe("ownComment", function(){ it("returns true if the author diaspora_id == the current user's diaspora_id", function(){ - loginAs(this.comment.get("author")) - expect(this.view.ownComment()).toBe(true) - }) + loginAs(this.comment.get("author")); + expect(this.view.ownComment()).toBe(true); + }); it("returns false if the author diaspora_id != the current user's diaspora_id", function(){ - loginAs(factory.author({diaspora_id : "notbob@bob.com"})) + loginAs(factory.author({diaspora_id : "notbob@bob.com"})); expect(this.view.ownComment()).toBe(false); - }) - }) + }); + }); describe("postOwner", function(){ it("returns true if the author diaspora_id == the current user's diaspora_id", function(){ - loginAs(this.post.get("author")) - expect(this.view.postOwner()).toBe(true) - }) + loginAs(this.post.get("author")); + expect(this.view.postOwner()).toBe(true); + }); it("returns false if the author diaspora_id != the current user's diaspora_id", function(){ - loginAs(factory.author({diaspora_id : "notbob@bob.com"})) + loginAs(factory.author({diaspora_id : "notbob@bob.com"})); expect(this.view.postOwner()).toBe(false); - }) - }) + }); + }); describe("canRemove", function(){ context("is truthy", function(){ it("when ownComment is true", function(){ - spyOn(this.view, "ownComment").and.returnValue(true) - spyOn(this.view, "postOwner").and.returnValue(false) + spyOn(this.view, "ownComment").and.returnValue(true); + spyOn(this.view, "postOwner").and.returnValue(false); - expect(this.view.canRemove()).toBe(true) - }) + expect(this.view.canRemove()).toBe(true); + }); it("when postOwner is true", function(){ - spyOn(this.view, "postOwner").and.returnValue(true) - spyOn(this.view, "ownComment").and.returnValue(false) + spyOn(this.view, "postOwner").and.returnValue(true); + spyOn(this.view, "ownComment").and.returnValue(false); - expect(this.view.canRemove()).toBe(true) - }) - }) + expect(this.view.canRemove()).toBe(true); + }); + }); context("is falsy", function(){ it("when postOwner and ownComment are both false", function(){ - spyOn(this.view, "postOwner").and.returnValue(false) - spyOn(this.view, "ownComment").and.returnValue(false) + spyOn(this.view, "postOwner").and.returnValue(false); + spyOn(this.view, "ownComment").and.returnValue(false); - expect(this.view.canRemove()).toBe(false) - }) - }) - }) -}) + expect(this.view.canRemove()).toBe(false); + }); + }); + }); +}); diff --git a/spec/javascripts/app/views/content_view_spec.js b/spec/javascripts/app/views/content_view_spec.js index d7a4442d6d4f08aa2d6f8f4bdeb9e93d8ce1a90a..8f42a247fb6782a9bd04c132b13f4bcdf0cd4a41 100644 --- a/spec/javascripts/app/views/content_view_spec.js +++ b/spec/javascripts/app/views/content_view_spec.js @@ -1,15 +1,13 @@ describe("app.views.Content", function(){ beforeEach(function(){ this.post = new app.models.StatusMessage(); - this.view = new app.views.Content({model : this.post}) + this.view = new app.views.Content({model : this.post}); }); describe("rendering", function(){ - it("should return all but the first photo from the post", function() { - this.post.set({photos : [1,2]}) // set 2 Photos - expect(this.view.smallPhotos().length).toEqual(1) + this.post.set({photos : [1,2]}); // set 2 Photos + expect(this.view.smallPhotos().length).toEqual(1); }); - }); -}); \ No newline at end of file +}); diff --git a/spec/javascripts/app/views/feedback_view_spec.js b/spec/javascripts/app/views/feedback_view_spec.js index e44714cf9120ec9ecfdcb1d036cc99980045ec3a..654b577101f81df22c1e9f2feca2d1d175fd4880 100644 --- a/spec/javascripts/app/views/feedback_view_spec.js +++ b/spec/javascripts/app/views/feedback_view_spec.js @@ -7,7 +7,7 @@ describe("app.views.Feedback", function(){ 'unlike' : "Unlike", 'public' : "Public", 'limited' : "Limted" - }}) + }}); var posts = $.parseJSON(spec.readFixture("stream_json")); @@ -18,45 +18,45 @@ describe("app.views.Feedback", function(){ describe("triggers", function() { it('re-renders when the model triggers feedback', 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(".render", function(){ beforeEach(function(){ - this.link = function(){ return this.view.$("a.like"); } + this.link = function(){ return this.view.$("a.like"); }; this.view.render(); - }) + }); context("likes", function(){ it("calls 'toggleLike' on the target post", function(){ - loginAs(this.post.interactions.likes.models[0].get("author")) + loginAs(this.post.interactions.likes.models[0].get("author")); this.view.render(); spyOn(this.post.interactions, "toggleLike"); this.link().click(); expect(this.post.interactions.toggleLike).toHaveBeenCalled(); - }) + }); context("when the user likes the post", function(){ it("the like action should be 'Unlike'", function(){ spyOn(this.post.interactions, "userLike").and.returnValue(factory.like()); - this.view.render() - expect(this.link().text()).toContain(Diaspora.I18n.t('stream.unlike')) - }) - }) + this.view.render(); + expect(this.link().text()).toContain(Diaspora.I18n.t('stream.unlike')); + }); + }); context("when the user doesn't yet like the post", function(){ beforeEach(function(){ this.view.model.set({user_like : null}); this.view.render(); - }) + }); it("the like action should be 'Like'", function(){ - expect(this.link().text()).toContain(Diaspora.I18n.t('stream.like')) - }) + expect(this.link().text()).toContain(Diaspora.I18n.t('stream.like')); + }); it("allows for unliking a just-liked post", function(){ // callback stuff.... we should fix this @@ -68,80 +68,79 @@ describe("app.views.Feedback", function(){ // this.link().click(); // expect(this.link().text()).toContain(Diaspora.I18n.t('stream.like')) - }) - }) - }) + }); + }); + }); context("when the post is public", function(){ beforeEach(function(){ this.post.attributes.public = true; this.view.render(); - }) + }); it("shows 'Public'", function(){ - expect($(this.view.el).html()).toContain(Diaspora.I18n.t('stream.public')) - }) + expect($(this.view.el).html()).toContain(Diaspora.I18n.t('stream.public')); + }); it("shows a reshare_action link", function(){ - expect(this.view.$("a.reshare")).toExist() + expect(this.view.$("a.reshare")).toExist(); }); it("does not show a reshare_action link if the original post has been deleted", function(){ - this.post.set({post_type : "Reshare", root : null}) + this.post.set({post_type : "Reshare", root : null}); this.view.render(); - expect(this.view.$("a.reshare")).not.toExist() - }) - }) + expect(this.view.$("a.reshare")).not.toExist(); + }); + }); context("when the post is not public", function(){ beforeEach(function(){ this.post.attributes.public = false; this.post.attributes.root = {author : {name : "susan"}}; this.view.render(); - }) + }); it("shows 'Limited'", function(){ - expect($(this.view.el).html()).toContain(Diaspora.I18n.t('stream.limited')) - }) + expect($(this.view.el).html()).toContain(Diaspora.I18n.t('stream.limited')); + }); it("does not show a reshare_action link", function(){ - expect(this.view.$("a.reshare")).not.toExist() + expect(this.view.$("a.reshare")).not.toExist(); }); - }) + }); context("when the current user owns the post", function(){ beforeEach(function(){ this.post.attributes.author = app.currentUser; this.view.render(); - }) + }); it("does not display a reshare_action link", function(){ - this.post.attributes.public = false + this.post.attributes.public = false; this.view.render(); - expect(this.view.$("a.reshare")).not.toExist() - }) - }) - }) + expect(this.view.$("a.reshare")).not.toExist(); + }); + }); + }); describe("resharePost", function(){ beforeEach(function(){ - this.post.attributes.public = true + this.post.attributes.public = true; this.post.attributes.root = {author : {name : "susan"}}; this.view.render(); - }) + }); it("displays a confirmation dialog", function(){ - spyOn(window, "confirm") + spyOn(window, "confirm"); this.view.$("a.reshare").first().click(); expect(window.confirm).toHaveBeenCalled(); - }) + }); it("reshares the model", function(){ spyOn(window, "confirm").and.returnValue(true); - spyOn(this.view.model.reshare(), "save").and.returnValue(new $.Deferred()) + spyOn(this.view.model.reshare(), "save").and.returnValue(new $.Deferred()); this.view.$("a.reshare").first().click(); expect(this.view.model.reshare().save).toHaveBeenCalled(); - }) - }) -}) - + }); + }); +}); diff --git a/spec/javascripts/app/views/header_view_spec.js b/spec/javascripts/app/views/header_view_spec.js index dfa055d5adcf2ca9ac3bf4ab6db2891dc8807a7d..a386504d3a3505184ba0fa24dc1f0c40bd8fe9e4 100644 --- a/spec/javascripts/app/views/header_view_spec.js +++ b/spec/javascripts/app/views/header_view_spec.js @@ -1,6 +1,6 @@ describe("app.views.Header", function() { beforeEach(function() { - this.userAttrs = {name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}} + this.userAttrs = {name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}; loginAs(this.userAttrs); @@ -11,48 +11,48 @@ describe("app.views.Header", function() { describe("render", function(){ context("notifications badge", function(){ it("displays a count when the current user has a notification", function(){ - loginAs(_.extend(this.userAttrs, {notifications_count : 1})) + loginAs(_.extend(this.userAttrs, {notifications_count : 1})); this.view.render(); expect(this.view.$("#notification_badge .badge_count").hasClass('hidden')).toBe(false); expect(this.view.$("#notification_badge .badge_count").text()).toContain("1"); - }) + }); it("does not display a count when the current user has a notification", function(){ - loginAs(_.extend(this.userAttrs, {notifications_count : 0})) + loginAs(_.extend(this.userAttrs, {notifications_count : 0})); this.view.render(); expect(this.view.$("#notification_badge .badge_count").hasClass('hidden')).toBe(true); - }) - }) + }); + }); context("conversations badge", function(){ it("displays a count when the current user has a notification", function(){ - loginAs(_.extend(this.userAttrs, {unread_messages_count : 1})) + loginAs(_.extend(this.userAttrs, {unread_messages_count : 1})); this.view.render(); expect(this.view.$("#conversations_badge .badge_count").hasClass('hidden')).toBe(false); expect(this.view.$("#conversations_badge .badge_count").text()).toContain("1"); - }) + }); it("does not display a count when the current user has a notification", function(){ - loginAs(_.extend(this.userAttrs, {unread_messages_count : 0})) + loginAs(_.extend(this.userAttrs, {unread_messages_count : 0})); this.view.render(); expect(this.view.$("#conversations_badge .badge_count").hasClass('hidden')).toBe(true); - }) - }) + }); + }); context("admin link", function(){ it("displays if the current user is an admin", function(){ - loginAs(_.extend(this.userAttrs, {admin : true})) + loginAs(_.extend(this.userAttrs, {admin : true})); this.view.render(); expect(this.view.$("#user_menu").html()).toContain("/admins"); - }) + }); it("does not display if the current user is not an admin", function(){ - loginAs(_.extend(this.userAttrs, {admin : false})) + loginAs(_.extend(this.userAttrs, {admin : false})); this.view.render(); expect(this.view.$("#user_menu").html()).not.toContain("/admins"); - }) - }) - }) + }); + }); + }); describe("#toggleDropdown", function() { it("adds the class 'active'", function() { diff --git a/spec/javascripts/app/views/likes_info_view_spec.js b/spec/javascripts/app/views/likes_info_view_spec.js index 9f4648a205cb0495bb58405e181a1610b9e78a25..9e57f6c631f89e1b3f209d24b01a636f9b96d43e 100644 --- a/spec/javascripts/app/views/likes_info_view_spec.js +++ b/spec/javascripts/app/views/likes_info_view_spec.js @@ -7,7 +7,7 @@ describe("app.views.LikesInfo", function(){ zero : "<%= count %> 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 68e5ac59bf864a9d2c12f5bed33b8fbdb57cc6a8..42e04741c27feb797e6e9d33205b60148d7174c9 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 7af824d2078acd7ebb2ebef3b5e2e79f4ad8ea5e..f46f8c91c5e61e499b26ba0c8ee7963c95f3404e 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 d17c345baead9ac567cedec6a14a7e420a56fcd9..77bba41a167c43d52abe37127078a2cb8334d307 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 6f25d580b6b646912a491f81a12a1ad26ad7d202..645f50d2123026c736f6c6258b6a98e191d50047 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 04124467cf90cac10d025db690bf62fe3839b407..8f86d6eb386b93e5e9d2f9ae4fb245e78abd7935 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 eb3d35a5510c4fea8633e0d3e92754fce19c6c19..ca38368bc57b0b6d0510fe3146b6914be3777798 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($("<li>")) + self.view.el_photozone.append($("<li>")); }); 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("<input name='photos[]' value='3'/>") + $(this.view.el).prepend("<input name='photos[]' value='3'/>"); 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('<div id="location"></div>'); @@ -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 259dcd07435bcc1ed59e0c15ae78451aa9d21cad..98d24897a188079ef294c4572ed7a067cbed8250 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}) - - app.stream = new app.models.Stream() + 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.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 307ac8156bd078a8869176884fbe7c2766afafec..e26618492ada607b2a92ce1e255c72880196ec12 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 3935d13a2731ed372091fadeab3273fd884c23e9..4127282224082efeb7364c38dfe4f6d9db3fd7e1 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 29f8b275c462803cfabcef6268de7e59f912cb74..8639ee5fa86ec7e4d5d4c2141bb0c88d331a0bd5 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 cf54c6eb0833caa4b63951c4f6ca86792bdbb2e1..ec88615773e39b62db0a6823759eea4c510c1c00 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("<div class=subview1/>") - $(this.el).append("<div class=subview2/>") + $(this.el).append("<div class=subview1/>"); + $(this.el).append("<div class=subview2/>"); }, 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" - - spyOn($.fn, "tooltip") - this.view.render() - expect($.fn.tooltip.calls.mostRecent().object.selector).toBe(".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"); + }); + }); + }); +}); diff --git a/spec/javascripts/diaspora-spec.js b/spec/javascripts/diaspora-spec.js index 9c85666e5142dd1075afcb3f3401edd430b3f57e..3376c1e45f373a1308a0ea2c8f26943be43cbb7e 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 5c80a22465244b1632969f7008e29166c1890d9a..14bf5d491c883f27852052c81b5d8b6831b55eac 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 34e96045bc6ebbfeb41da0b9e06ce42d969c1555..e52cb683ca1e35cf68d2c1092dbe4ee9515097a5 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 dbd6bcf3d5034be4208bb315603d7ccf4c265773..f1f86d07e61321f408dd4c12463c187570251cea 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 ae6424a21aadb0fb0a472f9a2371bda7c4ef8838..5808daa6a1b0ac261f81dc434d1f10447d2a98fe 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 be404d73e2f531756d9d06d8628b9941a8ebc2a6..2315957ce93afb27cbb0acd9aa2796cc8d038fa2 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 f67955f82e5db4a984c01eb024072bdb5462a64d..9fd08458bb3aa6e1f7cd585bde2e2dec7fc3a5c6 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() {