downcase namespacing of app
This commit is contained in:
parent
6ad4c8e348
commit
1a5e493b22
27 changed files with 75 additions and 75 deletions
|
|
@ -61,7 +61,7 @@
|
|||
- unless @landing_page
|
||||
= include_javascripts :main
|
||||
:javascript
|
||||
App.user({
|
||||
app.user({
|
||||
current_user: #{current_user.person.as_api_response(:backbone).to_json}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
var App = {
|
||||
Collections: {},
|
||||
Models: {},
|
||||
Views: {},
|
||||
var app = {
|
||||
collections: {},
|
||||
models: {},
|
||||
views: {},
|
||||
|
||||
user: function(user) {
|
||||
if(user) { return this._user = user; }
|
||||
|
|
@ -10,16 +10,16 @@ var App = {
|
|||
},
|
||||
|
||||
initialize: function() {
|
||||
App.router = new App.Router;
|
||||
app.router = new app.Router;
|
||||
|
||||
if(this._user){
|
||||
App.header = new App.Views.Header;
|
||||
$("body").prepend(App.header.el);
|
||||
App.header.render();
|
||||
app.header = new app.views.Header;
|
||||
$("body").prepend(app.header.el);
|
||||
app.header.render();
|
||||
}
|
||||
|
||||
Backbone.history.start({pushState: true});
|
||||
}
|
||||
};
|
||||
|
||||
$(function() { App.initialize(); });
|
||||
$(function() { app.initialize(); });
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
App.Collections.Comments = Backbone.Collection.extend({
|
||||
model: App.Models.Comment
|
||||
app.collections.Comments = Backbone.Collection.extend({
|
||||
model: app.models.Comment
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
App.Collections.Likes = Backbone.Collection.extend({
|
||||
model: App.Models.Like
|
||||
app.collections.Likes = Backbone.Collection.extend({
|
||||
model: app.models.Like
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
App.Collections.Stream = Backbone.Collection.extend({
|
||||
app.collections.Stream = Backbone.Collection.extend({
|
||||
url: function() {
|
||||
var path = document.location.pathname + ".json";
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ App.Collections.Stream = Backbone.Collection.extend({
|
|||
return path;
|
||||
},
|
||||
|
||||
model: App.Models.Post,
|
||||
model: app.models.Post,
|
||||
|
||||
parse: function(resp){
|
||||
return resp.posts;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
App.Models.Comment = Backbone.Model.extend({
|
||||
app.models.Comment = Backbone.Model.extend({
|
||||
urlRoot: "/comments"
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
App.Models.Like = Backbone.Model.extend({
|
||||
app.models.Like = Backbone.Model.extend({
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
App.Models.Post = Backbone.Model.extend({
|
||||
app.models.Post = Backbone.Model.extend({
|
||||
initialize: function() {
|
||||
this.comments = new App.Collections.Comments(this.get("last_three_comments"));
|
||||
this.comments = new app.collections.Comments(this.get("last_three_comments"));
|
||||
this.comments.url = this.url() + '/comments';
|
||||
|
||||
this.likes = new App.Collections.Likes(this.get("user_like")); // load in the user like initially
|
||||
this.likes = new app.collections.Likes(this.get("user_like")); // load in the user like initially
|
||||
this.likes.url = this.url() + '/likes';
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
App.Router = Backbone.Router.extend({
|
||||
app.Router = Backbone.Router.extend({
|
||||
routes: {
|
||||
"stream": "stream",
|
||||
"comment_stream": "stream",
|
||||
|
|
@ -12,7 +12,7 @@ App.Router = Backbone.Router.extend({
|
|||
},
|
||||
|
||||
stream: function() {
|
||||
App.stream = new App.Views.Stream().render();
|
||||
$("#main_stream").html(App.stream.el);
|
||||
app.stream = new app.views.Stream().render();
|
||||
$("#main_stream").html(app.stream.el);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
App.Views.Base = Backbone.View.extend({
|
||||
app.views.Base = Backbone.View.extend({
|
||||
presenter : function(){
|
||||
return this.defaultPresenter()
|
||||
},
|
||||
|
||||
defaultPresenter : function(){
|
||||
var modelJson = this.model ? this.model.toJSON() : {}
|
||||
return _.extend(modelJson, App.user());
|
||||
return _.extend(modelJson, app.user());
|
||||
},
|
||||
|
||||
render : function() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
App.Views.Comment = App.Views.StreamObject.extend({
|
||||
app.views.Comment = app.views.StreamObject.extend({
|
||||
|
||||
template_name: "#comment-template",
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
App.Views.CommentStream = App.Views.Base.extend({
|
||||
app.views.CommentStream = app.views.Base.extend({
|
||||
|
||||
template_name: "#comment-stream-template",
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ App.Views.CommentStream = App.Views.Base.extend({
|
|||
},
|
||||
|
||||
appendComment: function(comment) {
|
||||
this.$("ul.comments").append(new App.Views.Comment({
|
||||
this.$("ul.comments").append(new app.views.Comment({
|
||||
model: comment
|
||||
}).render().el);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
App.Views.Feedback = App.Views.StreamObject.extend({
|
||||
app.views.Feedback = app.views.StreamObject.extend({
|
||||
template_name: "#feedback-template",
|
||||
|
||||
events: {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
App.Views.Header = Backbone.View.extend({
|
||||
app.views.Header = Backbone.View.extend({
|
||||
|
||||
events : {
|
||||
"click ul.dropdown li:first-child" : "toggleDropdown"
|
||||
|
|
@ -16,7 +16,7 @@ App.Views.Header = Backbone.View.extend({
|
|||
|
||||
render : function(){
|
||||
this.template = _.template($("#header-template").html());
|
||||
$(this.el).html(this.template(App.user()));
|
||||
$(this.el).html(this.template(app.user()));
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
App.Views.StatusMessage = App.Views.StreamObject.extend({
|
||||
app.views.StatusMessage = app.views.StreamObject.extend({
|
||||
template_name : "#status-message-template"
|
||||
});
|
||||
|
||||
App.Views.Reshare = App.Views.StreamObject.extend({
|
||||
app.views.Reshare = app.views.StreamObject.extend({
|
||||
template_name : "#reshare-template"
|
||||
});
|
||||
|
||||
App.Views.ActivityStreams__Photo = App.Views.StreamObject.extend({
|
||||
app.views.ActivityStreams__Photo = app.views.StreamObject.extend({
|
||||
template_name : "#activity-streams-photo-template"
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
App.Views.Post = App.Views.StreamObject.extend({
|
||||
app.views.Post = app.views.StreamObject.extend({
|
||||
|
||||
template_name: "#stream-element-template",
|
||||
|
||||
|
|
@ -16,8 +16,8 @@ App.Views.Post = App.Views.StreamObject.extend({
|
|||
},
|
||||
|
||||
initialize : function() {
|
||||
this.feedbackView = new App.Views.Feedback({model : this.model});
|
||||
this.commentStreamView = new App.Views.CommentStream({ model : this.model});
|
||||
this.feedbackView = new app.views.Feedback({model : this.model});
|
||||
this.commentStreamView = new app.views.CommentStream({ model : this.model});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
|
@ -33,7 +33,7 @@ App.Views.Post = App.Views.StreamObject.extend({
|
|||
|
||||
renderPostContent: function(){
|
||||
var normalizedClass = this.model.get("post_type").replace(/::/, "__");
|
||||
var postClass = App.Views[normalizedClass] || App.Views.StatusMessage;
|
||||
var postClass = app.views[normalizedClass] || app.views.StatusMessage;
|
||||
var postView = new postClass({ model : this.model });
|
||||
|
||||
this.$(".post-content").html(postView.render().el);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
App.Views.StreamObject = App.Views.Base.extend({
|
||||
app.views.StreamObject = app.views.Base.extend({
|
||||
className : "loaded",
|
||||
|
||||
initialize: function(options) {
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
App.Views.Stream = Backbone.View.extend({
|
||||
app.views.Stream = Backbone.View.extend({
|
||||
events: {
|
||||
"click #paginate": "render"
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
this.collection = this.collection || new App.Collections.Stream;
|
||||
this.collection = this.collection || new app.collections.Stream;
|
||||
this.collection.bind("add", this.appendPost, this);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
appendPost: function(post) {
|
||||
var postView = new App.Views.Post({ model: post });
|
||||
var postView = new app.views.Post({ model: post });
|
||||
$(this.el).append(postView.render().el);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@
|
|||
|
||||
// temp hack to check if backbone is enabled for the page
|
||||
Diaspora.backboneEnabled = function(){
|
||||
return window.App.router.routes[window.location.pathname.replace("/","")];
|
||||
return window.app.router.routes[window.location.pathname.replace("/","")];
|
||||
}
|
||||
|
||||
window.Diaspora = Diaspora;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
describe("App", function() {
|
||||
describe("app", function() {
|
||||
describe("user", function() {
|
||||
it("sets the user if given one and returns the current user", function() {
|
||||
expect(App.user()).toBeUndefined();
|
||||
expect(app.user()).toBeUndefined();
|
||||
|
||||
App.user({name: "alice"});
|
||||
app.user({name: "alice"});
|
||||
|
||||
expect(App.user()).toEqual({name: "alice"});
|
||||
expect(app.user()).toEqual({name: "alice"});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
describe("App.Models.Stream", function() {
|
||||
describe("app.collections.Stream", function() {
|
||||
describe("url", function() {
|
||||
var stream = new App.Collections.Stream(),
|
||||
var stream = new app.collections.Stream(),
|
||||
expectedPath = document.location.pathname + ".json";
|
||||
it("returns the json path", function() {
|
||||
expect(stream.url()).toEqual(expectedPath);
|
||||
});
|
||||
|
||||
it("returns the json path with max_time if the collection has models", function() {
|
||||
var post = new App.Models.Post();
|
||||
var post = new app.models.Post();
|
||||
spyOn(post, "createdAt").andReturn(1234);
|
||||
|
||||
stream.add(post);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
describe("App.Models.Post", function() {
|
||||
describe("app.models.Post", function() {
|
||||
describe("createdAt", function() {
|
||||
var post = new App.Models.Post();
|
||||
var post = new app.models.Post();
|
||||
it("returns the post's created_at as an integer", function() {
|
||||
var date = new Date;
|
||||
post.set({ created_at: +date * 1000 });
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
describe("App.views.Feedback", function(){
|
||||
describe("app.views.Feedback", function(){
|
||||
beforeEach(function(){
|
||||
window.current_user = App.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}});
|
||||
window.current_user = app.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}});
|
||||
|
||||
var posts = $.parseJSON(spec.readFixture("multi_stream_json"))["posts"];
|
||||
|
||||
this.post = new App.Models.Post(posts[2]);
|
||||
this.view = new App.Views.Feedback({model: this.post});
|
||||
this.post = new app.models.Post(posts[2]);
|
||||
this.view = new app.views.Feedback({model: this.post});
|
||||
});
|
||||
|
||||
it("has a like from the post", function(){
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
describe("App.Views.Header", function() {
|
||||
describe("app.views.Header", function() {
|
||||
beforeEach(function() {
|
||||
// should be jasmine helper
|
||||
window.current_user = App.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}});
|
||||
window.current_user = app.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}});
|
||||
|
||||
spec.loadFixture("aspects_index");
|
||||
this.view = new App.Views.Header().render();
|
||||
this.view = new app.views.Header().render();
|
||||
});
|
||||
|
||||
describe("#toggleDropdown", function() {
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
describe("App.views.Post", function(){
|
||||
describe("app.views.Post", function(){
|
||||
|
||||
describe("#render", function(){
|
||||
beforeEach(function(){
|
||||
// should be jasmine helper
|
||||
window.current_user = App.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}});
|
||||
window.current_user = app.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}});
|
||||
|
||||
var posts = $.parseJSON(spec.readFixture("multi_stream_json"))["posts"][0];
|
||||
|
||||
this.collection = new App.Collections.Stream(posts);
|
||||
this.collection = new app.collections.Stream(posts);
|
||||
this.statusMessage = this.collection.models[0];
|
||||
})
|
||||
|
||||
it("contains a '.like_action' link", function(){
|
||||
var view = new App.Views.Post({model : this.statusMessage}).render();
|
||||
var view = new app.views.Post({model : this.statusMessage}).render();
|
||||
var statusElement = $(view.el);
|
||||
|
||||
expect(statusElement.find(".like_action").html()).not.toBeNull();
|
||||
|
|
@ -22,7 +22,7 @@ describe("App.views.Post", function(){
|
|||
it("contains a shield element", function(){
|
||||
this.statusMessage.set({text : "this is safe for work. #sfw"});
|
||||
|
||||
var view = new App.Views.Post({model : this.statusMessage}).render();
|
||||
var view = new app.views.Post({model : this.statusMessage}).render();
|
||||
var statusElement = $(view.el)
|
||||
|
||||
expect(statusElement.find(".shield").html()).toBeNull();
|
||||
|
|
@ -31,7 +31,7 @@ describe("App.views.Post", function(){
|
|||
it("does not contain a shield element", function(){
|
||||
this.statusMessage.set({text : "nudie magazine day! #nsfw"});
|
||||
|
||||
var view = new App.Views.Post({model : this.statusMessage}).render();
|
||||
var view = new app.views.Post({model : this.statusMessage}).render();
|
||||
var statusElement = $(view.el)
|
||||
|
||||
expect(statusElement.find(".shield").html()).toNotBe(null);
|
||||
|
|
@ -40,7 +40,7 @@ describe("App.views.Post", function(){
|
|||
|
||||
context("Reshare link", function(){
|
||||
it("is present if the post is public", function(){
|
||||
var view = new App.Views.Post({model : this.statusMessage}).render();
|
||||
var view = new app.views.Post({model : this.statusMessage}).render();
|
||||
this.statusMessage.set({"public" : true});
|
||||
|
||||
var statusElement = $(view.el)
|
||||
|
|
@ -51,7 +51,7 @@ describe("App.views.Post", function(){
|
|||
it("is not present if the post is not public", function(){
|
||||
this.statusMessage.set({"public" : false});
|
||||
|
||||
var view = new App.Views.Post({model : this.statusMessage}).render();
|
||||
var view = new app.views.Post({model : this.statusMessage}).render();
|
||||
var statusElement = $(view.el)
|
||||
|
||||
expect(statusElement.find(".reshare_action").html()).toBeNull();
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
describe("App.views.Stream", function(){
|
||||
describe("app.views.Stream", function(){
|
||||
|
||||
describe("#render", function(){
|
||||
beforeEach(function(){
|
||||
// should be jasmine helper
|
||||
window.current_user = App.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}});
|
||||
window.current_user = app.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}});
|
||||
|
||||
var posts = $.parseJSON(spec.readFixture("multi_stream_json"))["posts"];
|
||||
|
||||
this.collection = new App.Collections.Stream(posts);
|
||||
this.collection = new app.collections.Stream(posts);
|
||||
this.statusMessage = this.collection.models[0];
|
||||
this.reshare = this.collection.models[1];
|
||||
|
||||
this.view = new App.Views.Stream({collection : this.collection});
|
||||
this.view = new app.views.Stream({collection : this.collection});
|
||||
this.view.render();
|
||||
this.statusElement = $(this.view.$("#" + this.statusMessage.get("guid")));
|
||||
this.reshareElement = $(this.view.$("#" + this.reshare.get("guid")));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
describe("App.Views.Base", function(){
|
||||
describe("app.views.Base", function(){
|
||||
function stubView(text){
|
||||
var stubClass = Backbone.View.extend({
|
||||
render : function(){
|
||||
|
|
@ -12,7 +12,7 @@ describe("App.Views.Base", function(){
|
|||
|
||||
describe("#render", function(){
|
||||
beforeEach(function(){
|
||||
var staticTemplateClass = App.Views.Base.extend({ template_name : "#static-text-template" })
|
||||
var staticTemplateClass = app.views.Base.extend({ template_name : "#static-text-template" })
|
||||
|
||||
this.model = new Backbone.Model({text : "model attributes are in the default presenter"})
|
||||
this.view = new staticTemplateClass({model: this.model})
|
||||
|
|
@ -31,7 +31,7 @@ describe("App.Views.Base", function(){
|
|||
|
||||
context("subViewRendering", function(){
|
||||
beforeEach(function(){
|
||||
var viewClass = App.Views.Base.extend({
|
||||
var viewClass = app.views.Base.extend({
|
||||
template_name : "#static-text-template",
|
||||
subviews : {
|
||||
".subview1": "subview1",
|
||||
|
|
|
|||
Loading…
Reference in a new issue