Very minor changes of some JS files
This commit is contained in:
parent
c703cadf9b
commit
df440ed8d8
27 changed files with 38 additions and 49 deletions
|
|
@ -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);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,3 @@ app.collections.Posts = Backbone.Collection.extend({
|
||||||
url : "/posts"
|
url : "/posts"
|
||||||
});
|
});
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,3 @@ app.collections.Reshares = Backbone.Collection.extend({
|
||||||
url : "/reshares"
|
url : "/reshares"
|
||||||
});
|
});
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,3 @@ app.models.AspectMembership = Backbone.Model.extend({
|
||||||
urlRoot: "/aspect_memberships"
|
urlRoot: "/aspect_memberships"
|
||||||
});
|
});
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,3 @@ app.models.Comment = Backbone.Model.extend({
|
||||||
urlRoot: "/comments"
|
urlRoot: "/comments"
|
||||||
});
|
});
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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() {
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,3 @@ app.models.StatusMessage = app.models.Post.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,4 +98,3 @@ app.pages.Contacts = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -127,4 +127,3 @@ app.pages.Profile = app.views.Base.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -170,9 +170,11 @@ app.Router = Backbone.Router.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
profile: function() {
|
profile: function() {
|
||||||
this.renderPage(function() { return new app.pages.Profile({
|
this.renderPage(function() {
|
||||||
el: $("body > #profile_container")
|
return new app.pages.Profile({
|
||||||
}); });
|
el: $("body > #profile_container")
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,4 +25,3 @@ var List = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
$.extend(Diaspora.Widgets[Widget].prototype, Diaspora.EventBroker.extend(Diaspora.BaseWidget));
|
$.extend(Diaspora.Widgets[Widget].prototype, Diaspora.EventBroker.extend(Diaspora.BaseWidget));
|
||||||
|
|
||||||
var widget = new Diaspora.Widgets[Widget](),
|
var widget = new Diaspora.Widgets[Widget](),
|
||||||
args = Array.prototype.slice.call(arguments, 1);
|
args = Array.prototype.slice.call(arguments, 1);
|
||||||
|
|
||||||
widget.publish("widget/ready", args);
|
widget.publish("widget/ready", args);
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@
|
||||||
Diaspora.page = new Page();
|
Diaspora.page = new Page();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$.mobile)//why does this need this?
|
if(!$.mobile) // why does this need this?
|
||||||
$.extend(Diaspora.page, new Diaspora.BasePage($(document.body)));
|
$.extend(Diaspora.page, new Diaspora.BasePage($(document.body)));
|
||||||
Diaspora.page.publish("page/ready", [$(document.body)]);
|
Diaspora.page.publish("page/ready", [$(document.body)]);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -46,4 +46,3 @@ var Mentions = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -81,4 +81,3 @@ $(document).ready(function(){
|
||||||
$(this).change(profileAspectDropDown_onchange);
|
$(this).change(profileAspectDropDown_onchange);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,4 +36,3 @@
|
||||||
Diaspora.Widgets.FlashMessages = FlashMessages;
|
Diaspora.Widgets.FlashMessages = FlashMessages;
|
||||||
})();
|
})();
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
|
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
|
||||||
|
|
||||||
/* Copyright (c) 2010-2011, Diaspora Inc. This file is
|
/* Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
* licensed under the Affero General Public License version 3 or later. See
|
* licensed under the Affero General Public License version 3 or later. See
|
||||||
* the COPYRIGHT file.
|
* the COPYRIGHT file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var InfiniteScroll = function() {
|
var InfiniteScroll = function() {
|
||||||
|
|
@ -59,4 +59,3 @@
|
||||||
Diaspora.Widgets.InfiniteScroll = InfiniteScroll;
|
Diaspora.Widgets.InfiniteScroll = InfiniteScroll;
|
||||||
})();
|
})();
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -190,4 +190,3 @@ jQuery.fn.center = (function() {
|
||||||
Diaspora.Widgets.Lightbox = Lightbox;
|
Diaspora.Widgets.Lightbox = Lightbox;
|
||||||
})();
|
})();
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
describe("bookmarklet", function(){
|
describe("bookmarklet", function(){
|
||||||
var fakeUrl = "http://pod.example.com/bookmarklet";
|
var fakeUrl = "http://pod.example.com/bookmarklet";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/* Copyright (c) 2010-2011, Diaspora Inc. This file is
|
/* Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
* licensed under the Affero General Public License version 3 or later. See
|
* licensed under the Affero General Public License version 3 or later. See
|
||||||
* the COPYRIGHT file.
|
* the COPYRIGHT file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
describe("View", function() {
|
describe("View", function() {
|
||||||
it("is the object that helps the UI", function() {
|
it("is the object that helps the UI", function() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue