diff options
Diffstat (limited to 'public/assets/javascripts/ui/SiteRouter.js')
| -rw-r--r-- | public/assets/javascripts/ui/SiteRouter.js | 84 |
1 files changed, 57 insertions, 27 deletions
diff --git a/public/assets/javascripts/ui/SiteRouter.js b/public/assets/javascripts/ui/SiteRouter.js index c224b6a..70523d7 100644 --- a/public/assets/javascripts/ui/SiteRouter.js +++ b/public/assets/javascripts/ui/SiteRouter.js @@ -15,22 +15,28 @@ var SiteRouter = Router.extend({ }, routes: { - "/login": 'signin', - "/signup": 'signup', - "/project/new": 'newProject', - "/profile": 'profile', - "/profile/edit": 'editProfile', - "/about/:name/edit": 'editDocument', - "/about/new": 'newDocument', - "/editor": 'launchEditor', - "/builder": 'pickLayout', - "/builder/:name": 'builder', + "/login": 'signin', + "/signup": 'signup', + "/profile": 'profile', + "/profile/edit": 'editProfile', + "/about/:name/edit": 'editDocument', + "/about/new": 'newDocument', + + "/layout": 'pickLayout', + "/layout/:name": 'layouts', + + "/project": 'pickProject', + "/project/new": 'newProject', + "/project/new/:layout": 'newProjectWithLayout', + "/project/:name": 'editor', }, initialize: function(){ this.signUpModal = new SignUpModal() this.signInModal = new SignInModal() this.layoutsModal = new LayoutsModal() + this.projectsModal = new ProjectsModal() + this.newProjectModal = new NewProjectModal() this.editProjectModal = new EditProjectModal() this.editProfileModal = new EditProfileModal() this.documentModal = new DocumentModal() @@ -39,7 +45,8 @@ var SiteRouter = Router.extend({ $("body").removeClass("loading") }, - + + builder: function(e, name){ app.mode.builder = true app.launch() @@ -50,18 +57,53 @@ var SiteRouter = Router.extend({ pickLayout: function(e){ e && e.preventDefault() - window.history.pushState(null, document.title, "/builder") + window.history.pushState(null, document.title, "/layout") this.layoutsModal.load() }, - launchEditor: function(){ + + pickProject: function(e){ + e && e.preventDefault() + window.history.pushState(null, document.title, "/project") + this.projectsModal.load() + }, + + newProject: function(e){ + e && e.preventDefault() + window.history.pushState(null, document.title, "/project/new") + this.newProjectModal.load() + }, + + newProjectWithLayout: function(e, layout){ + e && e.preventDefault() + + app.mode.editor = true + app.launch() + + layout = slugify(layout) + + window.history.pushState(null, document.title, "/project/new/" + layout) + this.editorView = new EditorView() + this.editorView.loadLayout(layout) + }, + + editor: function(e, layout){ app.mode.editor = true app.launch() this.editorView = new EditorView() - this.editorView.load() + this.editorView.loadLayout(name) }, + +/* + editProject: function(e){ + e && e.preventDefault() + window.history.pushState(null, document.title, "/project/edit") + this.editProjectModal.load() + }, +*/ + signup: function(e){ e && e.preventDefault() window.history.pushState(null, document.title, "/signup") @@ -74,19 +116,6 @@ var SiteRouter = Router.extend({ this.signInModal.load() }, - newProject: function(e){ - e && e.preventDefault() - window.history.pushState(null, document.title, "/project/new") - - this.layoutsModal.load() - }, - - editProject: function(e){ - e && e.preventDefault() - window.history.pushState(null, document.title, "/project/edit") - this.editProjectModal.load() - }, - profile: function(e){ var classes = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', @@ -102,6 +131,7 @@ var SiteRouter = Router.extend({ this.editProfileModal.load() }, + newDocument: function(e){ e && e.preventDefault() |
