diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-06-09 11:26:04 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-06-09 11:26:04 -0400 |
| commit | e5dc46846ce9fb1c990d291ef852c0cad3f74957 (patch) | |
| tree | 16de7362bcdb8d87e41f22f452f6b8e427e98ff1 /public/assets/javascripts/ui/Router.js | |
| parent | e8ba718205d41e75923264ef945178030b662c93 (diff) | |
editing profile
Diffstat (limited to 'public/assets/javascripts/ui/Router.js')
| -rw-r--r-- | public/assets/javascripts/ui/Router.js | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/public/assets/javascripts/ui/Router.js b/public/assets/javascripts/ui/Router.js new file mode 100644 index 0000000..a518e27 --- /dev/null +++ b/public/assets/javascripts/ui/Router.js @@ -0,0 +1,77 @@ + +var Router = View.extend({ + el: "body", + + events: { + "click [data-role='show-signup-modal']": 'signup', + "click [data-role='show-signin-modal']": 'signin', + "click [data-role='new-project-modal']": 'newProject', + "click [data-role='edit-project-modal']": 'editProject', + "click [data-role='edit-profile-modal']": 'editProfile', + }, + + routes: { + "/login": 'signin', + "/signup": 'signup', + "/project/new": 'newProject', + "/profile/edit": 'editProfile', + "/app": 'launch', + }, + + initialize: function(){ + this.signUpModal = new SignUpModal() + this.signInModal = new SignInModal() + this.newProjectModal = new NewProjectModal() + this.editProjectModal = new EditProjectModal() + this.editProfileModal = new EditProfileModal() + + this.originalPath = window.location.pathname + + for (var route in this.routes) { + if (window.location.pathname.indexOf(route) === 0) { + this[this.routes[route]]() + break; + } + } + + $("body").removeClass("loading") + }, + + launch: function(){ + app.launch() + }, + + signup: function(e){ + e && e.preventDefault() + window.history.pushState(null, document.title, "/signup") + this.signUpModal.load() + }, + + signin: function(e){ + e && e.preventDefault() + window.history.pushState(null, document.title, "/login") + this.signInModal.load() + }, + + newProject: function(e){ + e && e.preventDefault() + window.history.pushState(null, document.title, "/project/new") + + this.newProjectModal.load() + }, + + editProject: function(e){ + e && e.preventDefault() + window.history.pushState(null, document.title, "/project/edit") + this.editProjectModal.load() + }, + + editProfile: function(e){ + e && e.preventDefault() + window.history.pushState(null, document.title, "/profile/edit") + + this.editProfileModal.load() + }, + +}) + |
