Skip to content

Commit

Permalink
Making it easier to follow
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmaim committed Apr 19, 2012
1 parent 1feabe2 commit 1583bd1
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 22 deletions.
5 changes: 5 additions & 0 deletions index.html
Expand Up @@ -75,15 +75,20 @@ <h1>Super Top Friends</h1>
</div>
</script>

<!-- Vendor. -->
<script src="//connect.facebook.net/en_US/all.js"></script>
<script src="js/vendor/jquery-1.7.1.min.js"></script>
<script src="js/vendor/underscore.js"></script>
<script src="js/vendor/backbone.js"></script>
<!-- Models. -->
<script src="js/models/winners.js"></script>
<script src="js/models/friend.js"></script>
<!-- Collections. -->
<script src="js/collections/friends.js"></script>
<!-- Views. -->
<script src="js/views/landing.js"></script>
<script src="js/views/friends.js"></script>
<!-- App. -->
<script src="js/app.js"></script>
<script>
/* App start. */
Expand Down
11 changes: 8 additions & 3 deletions js/app.js
Expand Up @@ -10,11 +10,16 @@ $(function(){
}
, initialize: function(){
console.log('router:initialize');
/* Views. */
/* Models. */
this.winnersModel = new WinnersModel();
/* Collections.*/
this.friendsCollection = new FriendsCollection();
this.landingView = new LandingView({ collection: this.friendsCollection });
/* Views. */
this.landingView = new LandingView({
collection: this.friendsCollection
});
this.friendsView = new FriendsView({
modelnew WinnersModel()
modelthis.winnersModel
, collection: this.friendsCollection
});
/* Event binding. */
Expand Down
15 changes: 6 additions & 9 deletions js/collections/friends.js
@@ -1,28 +1,25 @@
window.FriendsCollection = Backbone.Collection.extend({
modelFriend
, from: 0
, offset: 6
, initialize: function(opts){
console.log('Friends:initialize');
modelFriendModel
, from: 0
, offset: 6
, access_token: null
, initialize: function(){
console.log('FriendsCollection:initialize');
}
, urlfunction(){
//console.log('Friends:url');
return 'https://graph.facebook.com/me/friends?access_token='+this.access_token;
}
, parsefunction(res) {
//console.log('Friends:parse');
res.data.sort(function(a,b){
return (a.name.toLowerCase() < b.name.toLowerCase())-1 : 1;
});
return res.data;
}
, nextfunction(){
console.log('from',this.from);
this.from += this.offset;
this.trigger('changePage');
}
, prevfunction(){
console.log('from',this.from);
this.from -= this.offset;
this.trigger('changePage');
}
Expand Down
7 changes: 5 additions & 2 deletions js/models/friend.js
@@ -1,5 +1,8 @@
window.Friend = Backbone.Model.extend({
window.FriendModel = Backbone.Model.extend({
initializefunction(){
console.log('Friend:initialize');
console.log('FriendModel:initialize');
}
});



3 changes: 3 additions & 0 deletions js/models/winners.js
Expand Up @@ -33,3 +33,6 @@ window.WinnersModel = Backbone.Model.extend({
}
}
});



9 changes: 4 additions & 5 deletions js/views/friends.js
Expand Up @@ -5,8 +5,8 @@ window.FriendsView = Backbone.View.extend({
_.bindAll(this, 'render');
this.template = _.template( $('#friends_view_template').html() );
/* Event bindings. */
this.model.bind('change', this.render);
this.collection.bind('reset', this.render);
this.model.bind('change', this.render);
}
, events : {
'click input[type=checkbox]' : 'clickChoice'
Expand All @@ -15,7 +15,7 @@ window.FriendsView = Backbone.View.extend({
, 'click #next''clickNext'
},
render : function(){
console.log('FriendsView:render',this.model.full);
console.log('FriendsView:render');
this.$el.html( this.template({
winners: this.model.toJSON()
, friendsthis.collection.toJSON()
Expand Down Expand Up @@ -47,9 +47,8 @@ window.FriendsView = Backbone.View.extend({
caption: 'My best friends are: '+friendsName,
description: 'Oh yeah!'
};
console.log(params);
FB.ui(params, function(res){
console.log(res);
FB.ui(params, function(res){
//console.log(res);
});
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions js/views/landing.js
Expand Up @@ -2,19 +2,19 @@ window.LandingView = Backbone.View.extend({
el : '#view_entry'
, initialize : function(){
console.log('LandingView:initialize');
this.template = _.template( $('#landing_view_template').html() );
FB.init({
appId : '301452643259358'
, status : true
, cookie : true
, xfbml : true
, oauth : true
});
this.template = _.template( $('#landing_view_template').html() );
}
, events : {
'click #login_btn' : 'clickLoginBtn'
},
render : function(){
}
, render : function(){
console.log('LandingView:render');
this.$el.html( this.template() );
return this;
Expand Down

0 comments on commit 1583bd1

Please sign in to comment.