13:ce5b6e9b69b2
Anton Shestakov <engored@ya.ru>, Fri, 28 Dec 2012 02:23:22 +0900
Change workspace title after it's loaded.

next change 24:fe92472b29b7
previous change 11:84505e73e061

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.workspaceTitleDisplayer = new Displayer({
el: $('.workspace-title')
});
fruitbar.projectCounter = new CollectionCounterView({
el: $('.project-counter'),
collection: fruitbar.projects,
plurals: ['project', '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.done = function() {
return _(this).all(function(xhr) {
return xhr.readyState == 4;
});
};
fruitbar.xhrs.abort = function() {
_(this).each(function(xhr) {
xhr.abort();
});
this.length = 0;
};
fruitbar.on('workspace', function(workspace) {
$('body').stop().animate({opacity: 0});
this.xhrs.abort();
this.tasks.url = '/' + encodeURIComponent(workspace) + '/tasks/';
this.projects.url = '/' + encodeURIComponent(workspace) + '/projects/';
this.xhrs.push(this.tasks.fetch(), this.projects.fetch());
_(this.xhrs).each(function(fetch, index, xhrs) {
fetch.then(function() {
if (xhrs.done()) {
fruitbar.workspaceTitleDisplayer.render(workspace);
$('body').stop().animate({opacity: 1});
}
});
});
});
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();
});