9:8a7155aff782
Anton Shestakov <engored@ya.ru>, Thu, 27 Dec 2012 00:47:02 +0900
Abort all requests on workspace change.

next change 10:363ae86d0822
previous change 8:39ac2486b9d3

static/js/ui.js

Permissions: -rw-r--r--

Other formats: Feeds:
$(function() {
window.fruitbar = new Backbone.View();
fruitbar.tasks = new Tasks();
fruitbar.projects = new Projects();
fruitbar.router = new Router();
fruitbar.projectCounter = new CollectionCounterView({
el: $('.project-counter'),
collection: fruitbar.projects
});
fruitbar.projectsView = new ProjectsView({
el: $('.projects'),
collection: fruitbar.projects,
tasks: fruitbar.tasks,
templates: {
project: $('#project-template').html(),
task: $('#task-template').html()
},
controls: {
create: $('.btn-new-project')
}
});
fruitbar.xhrs = [];
fruitbar.xhrs.abort = function() {
_(this).each(function(xhr) {
xhr.abort();
});
this.length = 0;
};
fruitbar.on('workspace', function(workspace) {
this.xhrs.abort();
this.tasks.url = '/' + encodeURIComponent(workspace) + '/tasks/';
this.projects.url = '/' + encodeURIComponent(workspace) + '/projects/';
this.xhrs.push(this.tasks.fetch(), this.projects.fetch());
});
fruitbar.once('workspace', function() {
window.setInterval(function() {
fruitbar.xhrs.push(fruitbar.tasks.fetch({update: true}));
}, 60000);
window.setInterval(function() {
fruitbar.xhrs.push(fruitbar.projects.fetch({update: true}));
}, 60000);
});
Backbone.history.start();
});