Download:
child 12:2c9942109f13
parent 10:363ae86d0822
11:84505e73e061
Anton Shestakov <engored@ya.ru>, Fri, 28 Dec 2012 01:43:34 +0900
Display workspace title; label the project counter.

3 файлов изменено, 26 вставок(+), 4 удалений(-) [+]
static/js/framework/views/base.js file | annotate | diff | comparison | revisions
static/js/ui.js file | annotate | diff | comparison | revisions
templates/index.html file | annotate | diff | comparison | revisions
--- a/static/js/framework/views/base.js Thu Dec 27 02:42:10 2012 +0900
+++ b/static/js/framework/views/base.js Fri Dec 28 01:43:34 2012 +0900
@@ -28,8 +28,20 @@
}
});
+var Displayer = Backbone.View.extend({
+ render: function(text) {
+ this.$el.text(text);
+ return this;
+ }
+});
+
var CollectionCounterView = CollectionView.extend({
initialize: function(options) {
+ if ('plurals' in options) {
+ this.makeTitle = function(n) {
+ return n + ' ' + options.plurals[n == 1 ? 0 : 1];
+ }
+ }
this.bindCollection();
},
appendItem: function() {
@@ -39,6 +51,9 @@
this.repopulate();
},
repopulate: function() {
- this.$el.html(this.collection.models.length);
+ this.$el.html(this.makeTitle(this.collection.models.length));
+ },
+ makeTitle: function(n) {
+ return n;
}
});
--- a/static/js/ui.js Thu Dec 27 02:42:10 2012 +0900
+++ b/static/js/ui.js Fri Dec 28 01:43:34 2012 +0900
@@ -4,9 +4,14 @@
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
+ collection: fruitbar.projects,
+ plurals: ['project', 'projects']
});
fruitbar.projectsView = new ProjectsView({
@@ -39,6 +44,8 @@
fruitbar.on('workspace', function(workspace) {
$('body').stop().animate({opacity: 0});
+ this.workspaceTitleDisplayer.render(workspace);
+
this.xhrs.abort();
this.tasks.url = '/' + encodeURIComponent(workspace) + '/tasks/';
--- a/templates/index.html Thu Dec 27 02:42:10 2012 +0900
+++ b/templates/index.html Fri Dec 28 01:43:34 2012 +0900
@@ -36,8 +36,8 @@
</h3>
</div>
<div class="span8">
- <h3 class="muted">
- All projects <small>(<span class="project-counter"></span>)</small>
+ <h3>
+ <span class="muted">Workspace</span> <span class="workspace-title"></span> <small>(<span class="project-counter"></span>)</small>
</h3>
<hr>
</div>