namespace view, model, and collection under App
This commit is contained in:
parent
dca3581ae2
commit
d4219799e4
3 changed files with 6 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
|||
var BackboneStream = Backbone.Collection.extend({
|
||||
App.Collections.Stream = Backbone.Collection.extend({
|
||||
url: function() {
|
||||
var path = document.location.pathname;
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ var BackboneStream = Backbone.Collection.extend({
|
|||
}
|
||||
},
|
||||
|
||||
model: Post,
|
||||
model: App.Models.Post,
|
||||
|
||||
parse: function(resp){
|
||||
return resp.posts;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
var Post = Backbone.Model.extend({
|
||||
App.Models.Post = Backbone.Model.extend({
|
||||
url: "/posts/:id",
|
||||
intTime: function(){
|
||||
return +new Date(this.get("created_at")) / 1000;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
$(function() {
|
||||
window.StreamView = Backbone.View.extend({
|
||||
App.Views.Stream = Backbone.View.extend({
|
||||
|
||||
el: $("#main_stream"),
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ $(function() {
|
|||
initialize: function(){
|
||||
_.bindAll(this, "appendPost", "collectionFetched");
|
||||
|
||||
this.collection = new window.BackboneStream;
|
||||
this.collection = new App.Collections.Stream;
|
||||
this.collection.bind("add", this.appendPost);
|
||||
this.loadMore();
|
||||
},
|
||||
|
|
@ -50,6 +50,6 @@ $(function() {
|
|||
});
|
||||
|
||||
if(window.useBackbone) {
|
||||
window.stream = new window.StreamView;
|
||||
window.stream = new App.Views.Stream;
|
||||
}
|
||||
});
|
||||
Loading…
Reference in a new issue