Very minor changes of some JS files

This commit is contained in:
Spanti Nicola (RyDroid) 2015-07-08 02:06:23 +02:00 committed by Spanti Nicola (RyDroid)
parent c703cadf9b
commit df440ed8d8
27 changed files with 38 additions and 49 deletions

View file

@ -63,7 +63,7 @@ var app = {
}, },
parsePreload : function(prop) { parsePreload : function(prop) {
if(!app.hasPreload(prop)) { return } if(!app.hasPreload(prop)) { return; }
var preload = window.gon.preloads[prop]; var preload = window.gon.preloads[prop];
delete window.gon.preloads[prop]; //prevent dirty state across navigates delete window.gon.preloads[prop]; //prevent dirty state across navigates
@ -112,7 +112,7 @@ var app = {
/* mixpanel wrapper function */ /* mixpanel wrapper function */
instrument : function(type, name, object, callback) { instrument : function(type, name, object, callback) {
if(!window.mixpanel) { return } if(!window.mixpanel) { return; }
window.mixpanel[type](name, object, callback); window.mixpanel[type](name, object, callback);
}, },

View file

@ -2,22 +2,22 @@
app.collections.Comments = Backbone.Collection.extend({ app.collections.Comments = Backbone.Collection.extend({
model: app.models.Comment, model: app.models.Comment,
url: function() { return _.result(this.post, 'url') + '/comments'; }, url: function() {
return _.result(this.post, "url") + "/comments";
},
initialize : function(models, options) { initialize : function(models, options) {
this.post = options.post; this.post = options.post;
}, },
make : function(text) { make : function(text) {
var self = this; var comment = new app.models.Comment({ "text": text });
var comment = new app.models.Comment({text: text });
var deferred = comment.save({}, { var deferred = comment.save({}, {
url: '/posts/'+this.post.id+'/comments', url: "/posts/"+ this.post.id +"/comments",
success: function() { success: function() {
comment.set({author: app.currentUser.toJSON(), parent: self.post }); comment.set({author: app.currentUser.toJSON(), parent: this.post });
self.add(comment); this.add(comment);
} }
}); });

View file

@ -5,4 +5,3 @@ app.collections.Posts = Backbone.Collection.extend({
url : "/posts" url : "/posts"
}); });
// @license-end // @license-end

View file

@ -5,4 +5,3 @@ app.collections.Reshares = Backbone.Collection.extend({
url : "/reshares" url : "/reshares"
}); });
// @license-end // @license-end

View file

@ -5,7 +5,6 @@
// Requires: // Requires:
// this = model with "created_at" attribute // this = model with "created_at" attribute
app.models.formatDateMixin = { app.models.formatDateMixin = {
timeOf: function(field) { timeOf: function(field) {
return app.helpers.dateFormatter.parse(this.get(field)) / 1000; return app.helpers.dateFormatter.parse(this.get(field)) / 1000;
}, },
@ -13,7 +12,5 @@ app.models.formatDateMixin = {
createdAt: function() { createdAt: function() {
return this.timeOf("created_at"); return this.timeOf("created_at");
} }
}; };
// @license-end // @license-end

View file

@ -8,4 +8,3 @@ app.models.AspectMembership = Backbone.Model.extend({
urlRoot: "/aspect_memberships" urlRoot: "/aspect_memberships"
}); });
// @license-end // @license-end

View file

@ -4,4 +4,3 @@ app.models.Comment = Backbone.Model.extend({
urlRoot: "/comments" urlRoot: "/comments"
}); });
// @license-end // @license-end

View file

@ -32,7 +32,7 @@ app.models.Post.Interactions = Backbone.Model.extend({
}, },
likesCount : function(){ 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(){ resharesCount : function(){
@ -44,12 +44,15 @@ app.models.Post.Interactions = Backbone.Model.extend({
}, },
userLike : function(){ 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(){ userReshare : function(){
return this.reshares.select(function(reshare){ 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() { toggleLike : function() {

View file

@ -21,4 +21,3 @@ app.models.StatusMessage = app.models.Post.extend({
} }
}); });
// @license-end // @license-end

View file

@ -17,7 +17,7 @@ app.models.StreamAspects = app.models.Stream.extend({
}, },
fetch: function() { fetch: function() {
if(this.isFetching()){ return false } if(this.isFetching()) { return false; }
var url = this.url(); var url = this.url();
var ids = this.aspects_ids; var ids = this.aspects_ids;
this.deferred = this.items.fetch(this._fetchOpts({url : url, data : { 'a_ids': ids }})) this.deferred = this.items.fetch(this._fetchOpts({url : url, data : { 'a_ids': ids }}))
@ -32,4 +32,3 @@ app.models.StreamAspects = app.models.Stream.extend({
} }
}); });
// @license-end // @license-end

View file

@ -98,4 +98,3 @@ app.pages.Contacts = Backbone.View.extend({
} }
}); });
// @license-end // @license-end

View file

@ -127,4 +127,3 @@ app.pages.Profile = app.views.Base.extend({
} }
}); });
// @license-end // @license-end

View file

@ -37,7 +37,6 @@ app.pages.SinglePostViewer = app.views.Base.extend({
//... and converts html to plain text //... and converts html to plain text
document.title = $('<div>').html(html_title).text(); document.title = $('<div>').html(html_title).text();
} }
}, }
}); });
// @license-end // @license-end

View file

@ -170,9 +170,11 @@ app.Router = Backbone.Router.extend({
}, },
profile: function() { profile: function() {
this.renderPage(function() { return new app.pages.Profile({ this.renderPage(function() {
return new app.pages.Profile({
el: $("body > #profile_container") el: $("body > #profile_container")
}); }); });
});
} }
}); });
// @license-end // @license-end

View file

@ -150,7 +150,6 @@ app.views.Base = Backbone.View.extend({
}); });
app.views.StaticContentView = app.views.Base.extend({ app.views.StaticContentView = app.views.Base.extend({
initialize : function(options) { initialize : function(options) {
this.templateName = options.templateName; this.templateName = options.templateName;
this.data = options.data; this.data = options.data;

View file

@ -6,4 +6,3 @@ jQuery.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase());
jQuery.browser.opera = /opera/.test(navigator.userAgent.toLowerCase()); jQuery.browser.opera = /opera/.test(navigator.userAgent.toLowerCase());
jQuery.browser.msie = /msie/.test(navigator.userAgent.toLowerCase()); jQuery.browser.msie = /msie/.test(navigator.userAgent.toLowerCase());
// @license-end // @license-end

View file

@ -25,4 +25,3 @@ var List = {
} }
}; };
// @license-end // @license-end

View file

@ -46,4 +46,3 @@ var Mentions = {
} }
}; };
// @license-end // @license-end

View file

@ -26,6 +26,7 @@ $(document).ready(function() {
showComments(toggleReactionsLink); showComments(toggleReactionsLink);
} }
} }
function hideComments(toggleReactionsLink) { function hideComments(toggleReactionsLink) {
var bottomBar = toggleReactionsLink.closest(".bottom_bar").first(), var bottomBar = toggleReactionsLink.closest(".bottom_bar").first(),
commentsContainer = commentsContainerLazy(bottomBar), commentsContainer = commentsContainerLazy(bottomBar),
@ -33,6 +34,7 @@ $(document).ready(function() {
existingCommentsContainer.hide(); existingCommentsContainer.hide();
toggleReactionsLink.removeClass("active"); toggleReactionsLink.removeClass("active");
} }
function showComments(toggleReactionsLink) { function showComments(toggleReactionsLink) {
var bottomBar = toggleReactionsLink.closest(".bottom_bar").first(), var bottomBar = toggleReactionsLink.closest(".bottom_bar").first(),
commentsContainer = commentsContainerLazy(bottomBar), commentsContainer = commentsContainerLazy(bottomBar),
@ -44,12 +46,14 @@ $(document).ready(function() {
showUnloadedComments(toggleReactionsLink, bottomBar, commentActionLink); showUnloadedComments(toggleReactionsLink, bottomBar, commentActionLink);
} }
} }
function showLoadedComments(toggleReactionsLink, existingCommentsContainer, commentActionLink) { function showLoadedComments(toggleReactionsLink, existingCommentsContainer, commentActionLink) {
existingCommentsContainer.show(); existingCommentsContainer.show();
showCommentBox(commentActionLink); showCommentBox(commentActionLink);
toggleReactionsLink.addClass("active"); toggleReactionsLink.addClass("active");
existingCommentsContainer.find("time.timeago").timeago(); existingCommentsContainer.find("time.timeago").timeago();
} }
function showUnloadedComments(toggleReactionsLink, bottomBar, commentActionLink) { function showUnloadedComments(toggleReactionsLink, bottomBar, commentActionLink) {
var commentsContainer = commentsContainerLazy(bottomBar); var commentsContainer = commentsContainerLazy(bottomBar);
$.ajax({ $.ajax({
@ -62,6 +66,7 @@ $(document).ready(function() {
} }
}); });
} }
function commentsContainerLazy(bottomBar) { function commentsContainerLazy(bottomBar) {
return function() { return function() {
return bottomBar.find(".comment_container").first(); return bottomBar.find(".comment_container").first();
@ -140,6 +145,7 @@ $(document).ready(function() {
return parseInt(match) + 1; return parseInt(match) + 1;
})); }));
} }
// Fix for no reactions // Fix for no reactions
function updateReactionCount(bottomBar) { function updateReactionCount(bottomBar) {
var toggleReactionsLink = bottomBar.find(".show_comments").first(); var toggleReactionsLink = bottomBar.find(".show_comments").first();

View file

@ -81,4 +81,3 @@ $(document).ready(function(){
$(this).change(profileAspectDropDown_onchange); $(this).change(profileAspectDropDown_onchange);
}); });
}); });

View file

@ -36,4 +36,3 @@
Diaspora.Widgets.FlashMessages = FlashMessages; Diaspora.Widgets.FlashMessages = FlashMessages;
})(); })();
// @license-end // @license-end

View file

@ -59,4 +59,3 @@
Diaspora.Widgets.InfiniteScroll = InfiniteScroll; Diaspora.Widgets.InfiniteScroll = InfiniteScroll;
})(); })();
// @license-end // @license-end

View file

@ -190,4 +190,3 @@ jQuery.fn.center = (function() {
Diaspora.Widgets.Lightbox = Lightbox; Diaspora.Widgets.Lightbox = Lightbox;
})(); })();
// @license-end // @license-end

View file

@ -1,5 +1,4 @@
describe("app.helpers.dateFormatter", function(){ describe("app.helpers.dateFormatter", function(){
beforeEach(function(){ beforeEach(function(){
this.statusMessage = factory.post(); this.statusMessage = factory.post();
this.formatter = app.helpers.dateFormatter; this.formatter = app.helpers.dateFormatter;

View file

@ -1,4 +1,3 @@
describe("bookmarklet", function(){ describe("bookmarklet", function(){
var fakeUrl = "http://pod.example.com/bookmarklet"; var fakeUrl = "http://pod.example.com/bookmarklet";