--- a/static/js/framework/collections.js Thu Dec 27 00:12:30 2012 +0900
+++ b/static/js/framework/collections.js Thu Dec 27 00:34:49 2012 +0900
var Projects = Backbone.Collection.extend({
- return '/' + encodeURIComponent(fruitbar.workspace) + '/projects/';
var Tasks = Backbone.Collection.extend({
- return '/' + encodeURIComponent(fruitbar.workspace) + '/tasks/';
--- a/static/js/framework/router.js Thu Dec 27 00:12:30 2012 +0900
+++ b/static/js/framework/router.js Thu Dec 27 00:34:49 2012 +0900
setWorkspace: function(workspace) {
- fruitbar.workspace = workspace;
- fruitbar.tasks.fetch();
- fruitbar.projects.fetch();
+ fruitbar.trigger('workspace', workspace);
--- a/static/js/ui.js Thu Dec 27 00:12:30 2012 +0900
+++ b/static/js/ui.js Thu Dec 27 00:34:49 2012 +0900
- window.fruitbar = {workspace: undefined};
+ window.fruitbar = new Backbone.View();
fruitbar.tasks = new Tasks();
fruitbar.projects = new Projects();
fruitbar.router = new Router();
- Backbone.history.start();
+ fruitbar.on('workspace', function(workspace) {
+ this.tasks.url = '/' + encodeURIComponent(workspace) + '/tasks/';
+ this.projects.url = '/' + encodeURIComponent(workspace) + '/projects/';
- window.setInterval(function() {fruitbar.projects.fetch({update: true});}, 60000);
- window.setInterval(function() {fruitbar.tasks.fetch({update: true});}, 60000);
+ fruitbar.once('workspace', function() {
+ window.setInterval(function() {fruitbar.projects.fetch({update: true});}, 60000);
+ window.setInterval(function() {fruitbar.tasks.fetch({update: true});}, 60000);
+ Backbone.history.start();