Skip to content

Commit

Permalink
Add default view for rendering list of pomodoros
Browse files Browse the repository at this point in the history
  • Loading branch information
oivoodoo committed Feb 8, 2012
1 parent 780ab09 commit f8757d8
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 18 deletions.
5 changes: 5 additions & 0 deletions config/assets.yml
@@ -0,0 +1,5 @@
package_assets: off
template_function: _.template

javascripts:
# Common javascript dependencies
9 changes: 7 additions & 2 deletions public/app/app.js
@@ -1,10 +1,15 @@
var App = {
Routers: {},
Models: {},
Views: {}
Collections: {},
Views: {
Pomodoros: {}
}
};

// initialize application settings and default router.
App.init = function() {
var router = App.Routers.Pomodoros();
var router = new App.Routers.Pomodoros();

Backbone.history.start();
};
4 changes: 4 additions & 0 deletions public/app/collections/pomodoros.js
@@ -0,0 +1,4 @@
App.Collections.Pomodoros = Backbone.Collection.extend({
model: App.Models.Pomodoro,
localStorage: new Store('pomodoros')
});
3 changes: 3 additions & 0 deletions public/app/models/pomodoro.js
@@ -0,0 +1,3 @@
App.Models.Pomodoro = Backbone.Model.extend({
localStorage: new Store('pomodoros')
});
16 changes: 11 additions & 5 deletions public/app/routers/pomodoros.js
@@ -1,10 +1,16 @@
var App.Routers.Pomodoros = Backbone.Router.extend({
App.Routers.Pomodoros = Backbone.Router.extend({
routes: {
'/', 'index'
}
'': 'index'
},

index: function() {
// Catch up all pomodoros from localStorage and then show in the listview.
//
var collection = new App.Collections.Pomodoros();
collection.fetch({
success: function() {
new App.Views.Pomodoros.List({
collection: collection
});
}
});
}
});
11 changes: 11 additions & 0 deletions public/app/views/pomodoros/list.js
@@ -0,0 +1,11 @@
App.Views.Pomodoros.List = Backbone.View.extend({
el: '#container',

initialize: function() {
this.render();
},

render: function() {
$(this.el).html('test');
}
});
8 changes: 5 additions & 3 deletions public/index.html
Expand Up @@ -19,6 +19,9 @@
<!-- client application files -->
<script src="/app/app.js" type="text/javascript" charset="utf-8"></script>
<script src="/app/routers/pomodoros.js" type="text/javascript" charset="utf-8"></script>
<script src="/app/models/pomodoro.js" type="text/javascript" charset="utf-8"></script>
<script src="/app/collections/pomodoros.js" type="text/javascript" charset="utf-8"></script>
<script src="/app/views/pomodoros/list.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>

Expand All @@ -28,9 +31,8 @@
<h1>Pomodoros</h1>
</div><!-- /header -->

<div data-role="content">
<ul data-role="listview" data-inset="true" data-filter="true">
</ul>
<div id='container' data-role="content">

</div><!-- /content -->

</div><!-- /page -->
Expand Down
8 changes: 0 additions & 8 deletions spec/javascripts/routers/pomodoros_spec.js

This file was deleted.

0 comments on commit f8757d8

Please sign in to comment.