Skip to content

Commit

Permalink
changed the way route resetting and active repo works
Browse files Browse the repository at this point in the history
  • Loading branch information
tbranyen committed Jun 24, 2012
1 parent 8ec0a53 commit 2211a2c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
6 changes: 3 additions & 3 deletions app/modules/repo.js
Expand Up @@ -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.
Expand All @@ -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");
}
Expand All @@ -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({
Expand Down
28 changes: 15 additions & 13 deletions app/router.js
Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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();
Expand All @@ -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
}),
Expand Down

0 comments on commit 2211a2c

Please sign in to comment.