diff --git a/app/modules/repo.js b/app/modules/repo.js index 7e283ac..4bfa7ac 100644 --- a/app/modules/repo.js +++ b/app/modules/repo.js @@ -59,7 +59,7 @@ function(app, Backbone, Commit) { var user = app.router.repos.user; // Immediately reflect the active state. - this.model.active = true; + app.active = this.model; this.render(); // Easily create a URL. @@ -69,7 +69,7 @@ function(app, Backbone, Commit) { }, render: function(manage) { - if (this.model.active) { + if (app.active === this.model) { this.$el.siblings().removeClass("active"); this.$el.addClass("active"); } @@ -88,7 +88,7 @@ function(app, Backbone, Commit) { this.collection.each(function(repo) { if (repo.get("name") === active) { - repo.active = true; + app.active = repo; } this.insertView("ul", new Repo.Views.Item({ diff --git a/app/router.js b/app/router.js index f492299..02b9da5 100644 --- a/app/router.js +++ b/app/router.js @@ -20,19 +20,13 @@ function(app, Repo, User, Commit) { }, index: function() { - // Reset to initial state. - this.users.reset(); - this.repos.reset(); - this.commits.reset(); - // Use the main layout. app.useLayout("main"); }, org: function(name) { // Reset to initial state. - this.repos.reset(); - this.commits.reset(); + this.reset(); // Use the main layout. app.useLayout("main"); @@ -46,7 +40,7 @@ function(app, Repo, User, Commit) { user: function(org, name) { // Reset to initial state. - this.commits.reset(); + this.reset(); // Use the main layout. app.useLayout("main"); @@ -84,6 +78,17 @@ function(app, Repo, User, Commit) { return this.navigate(_.toArray(arguments).join("/"), true); }, + reset: function() { + // Reset collections to initial state. + this.users.reset(); + this.repos.reset(); + this.commits.reset(); + + // Reset active model. + app.active = false; + this.commits.repo = false; + }, + initialize: function() { // Set up the users. this.users = new User.Collection(); @@ -92,11 +97,8 @@ function(app, Repo, User, Commit) { // Set up the commits. this.commits = new Commit.Collection(); - // Start with the default layout. - app.useLayout("main"); - - // Set all the views. - app.layout.setViews({ + // Use main layout and set Views. + app.useLayout("main").setViews({ ".users": new User.Views.List({ collection: this.users }),