diff options
Diffstat (limited to 'public/assets/javascripts/ui/MasterView.js')
| -rw-r--r-- | public/assets/javascripts/ui/MasterView.js | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/public/assets/javascripts/ui/MasterView.js b/public/assets/javascripts/ui/MasterView.js index e99777e..a39c6f0 100644 --- a/public/assets/javascripts/ui/MasterView.js +++ b/public/assets/javascripts/ui/MasterView.js @@ -3,47 +3,72 @@ var MasterView = View.extend({ el: "body", events: { - "click [data-role='show-signup-modal']": 'showSignUpModal', - "click [data-role='show-signin-modal']": 'showSignInModal', - "click [data-role='create-project-modal']": 'showCreateProjectModal', - "click [data-role='edit-project-modal']": 'showEditProjectModal', - "click [data-role='edit-profile-modal']": 'showEditProfileModal', + "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.createProjectModal = new CreateProjectModal() + this.newProjectModal = new NewProjectModal() this.editProjectModal = new EditProjectModal() this.editProfileModal = new EditProfileModal() + + for (var route in this.routes) { + if (window.location.pathname.indexOf(route) === 0) { + this[this.routes[route]]() + break; + } + } $("body").removeClass("loading") - // app.launch() - }, - showSignUpModal: function(e){ - e.preventDefault() + launch: function(){ + app.launch() + }, + + signup: function(e){ + e && e.preventDefault() + window.history.pushState(null, document.title, "/signup") this.signUpModal.load() }, - showSignInModal: function(e){ - e.preventDefault() + signin: function(e){ + e && e.preventDefault() + window.history.pushState(null, document.title, "/login") this.signInModal.load() }, - showCreateProjectModal: function(e){ - e.preventDefault() - this.createProjectModal.load() + newProject: function(e){ + e && e.preventDefault() + window.history.pushState(null, document.title, "/project/new") + + this.newProjectModal.load() }, - showEditProjectModal: function(e){ - e.preventDefault() + editProject: function(e){ + e && e.preventDefault() + window.history.pushState(null, document.title, "/project/edit") + this.editProjectModal.load() }, - showEditProfileModal: function(e){ - e.preventDefault() + editProfile: function(e){ + e && e.preventDefault() + window.history.pushState(null, document.title, "/profile/edit") + this.editProfileModal.load() }, |
