Created
July 20, 2012 18:24
-
-
Save krusty/3152417 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
var account = new Account.Model(), | |
choices = new CatalogChoice.List(), | |
login = new Login.Views.Form(), | |
header = new Account.Views.Header({model: account}), | |
results = new Company.Views.Results(), | |
summary = new CatalogChoice.Views.Summary({collection: choices}), | |
welcome = new Pages.Welcome({model: account}), | |
dashboard = new Pages.Dashboard({model: account}), | |
signup = new Pages.Signup({model: account}), | |
newChoice = new Pages.NewChoice({model: account}); | |
dispatcher.on('login', function () { | |
account.fetch(); | |
choices.fetch(); | |
welcome.hide(); | |
signup.hide(); | |
dashboard.show(); | |
login.$el.hide(); | |
$('#user').append(header.$el); | |
}); | |
dispatcher.on('logout', function () { | |
dashboard.hide(); | |
newChoice.hide(); | |
welcome.show(); | |
header.$el.html(''); | |
login.$el.show(); | |
}); | |
dispatcher.on('signup', function () { | |
welcome.hide(); | |
signup.show(); | |
}); | |
dispatcher.on('new-choice', function (catalog) { | |
dashboard.hide(); | |
newChoice.show(); | |
}); | |
dispatcher.on('dashboard', function (catalog) { | |
choices.fetch(); | |
dispatcher.trigger('reset'); | |
newChoice.hide(); | |
dashboard.show(); | |
}); | |
//initial page | |
if (store.get('access_token')) { | |
dispatcher.trigger('login'); | |
} else { | |
welcome.show(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment