diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-06-10 12:00:24 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-06-10 12:00:24 -0400 |
| commit | 9fb0fe9b7ef614d2248b00ea2b964205f3453f41 (patch) | |
| tree | 953fd956e1c6b3d641226d7ac36cc749ced92504 /public/assets/javascripts/ui/Router.js | |
| parent | 3f8e4223cc57bc3fd461881e3d6e9eb331bf4dc5 (diff) | |
split up builder functionality
Diffstat (limited to 'public/assets/javascripts/ui/Router.js')
| -rw-r--r-- | public/assets/javascripts/ui/Router.js | 151 |
1 files changed, 0 insertions, 151 deletions
diff --git a/public/assets/javascripts/ui/Router.js b/public/assets/javascripts/ui/Router.js deleted file mode 100644 index 5b75162..0000000 --- a/public/assets/javascripts/ui/Router.js +++ /dev/null @@ -1,151 +0,0 @@ - -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', - "click [data-role='new-document-modal']": 'newDocument', - "click [data-role='edit-document-modal']": 'editDocument', - "click [data-role='delete-document-modal']": 'destroyDocument', - }, - - routes: { - "/login": 'signin', - "/signup": 'signup', - "/project/new": 'newProject', - "/profile": 'profile', - "/profile/edit": 'editProfile', - "/about/:name/edit": 'editDocument', - "/about/new": 'newDocument', - "/editor": 'launchEditor', - "/builder": 'launchBuilder', - }, - - initialize: function(){ - this.builderView = new BuilderView() - this.editorView = new EditorView() - this.signUpModal = new SignUpModal() - this.signInModal = new SignInModal() - this.newProjectModal = new NewProjectModal() - this.editProjectModal = new EditProjectModal() - this.editProfileModal = new EditProfileModal() - this.documentModal = new DocumentModal() - this.confirmModal = new ConfirmModal() - this.alertModal = new AlertModal() - - this.originalPath = window.location.pathname - - var path = window.location.pathname.split("/") - // console.log(path) - for (var route in this.routes) { - var routePath = route.split("/") - if (routePath[1] == path[1]) { - if (routePath[2] && routePath[2].indexOf(":") !== -1 && path[2] && (path[3] === routePath[3]) ) { - this[this.routes[route]](null, path[2]) - break; - } - else if (routePath[2] == path[2]) { - this[this.routes[route]](null) - break; - } - else if (! routePath[2] && (! path[2].length || ! path[2])) { - this[this.routes[route]](null) - break; - } - } - } - - $("body").removeClass("loading") - }, - - launchBuilder: function(){ - app.mode.builder = true - app.launch() - this.builderView.load() - }, - - launchEditor: function(){ - app.mode.editor = true - app.launch() - this.editorView.load() - }, - - 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() - }, - - profile: function(e){ - var classes = ['one', 'two', 'three', 'four', - 'five', 'six', 'seven', 'eight', - 'nine', 'ten', 'eleven', 'twelve', - 'thirteen']; - $(".bio").addClass(choice(classes)); - }, - - editProfile: function(e){ - e && e.preventDefault() - window.history.pushState(null, document.title, "/profile/edit") - - this.editProfileModal.load() - }, - - newDocument: function(e){ - e && e.preventDefault() - - var name = e ? $(e.currentTarget).data("name") : "new" - - window.history.pushState(null, document.title, "/about/new") - this.documentModal.load(name, true) - }, - - editDocument: function(e, name){ - e && e.preventDefault() - - var name = e ? $(e.currentTarget).data("name") : name - window.history.pushState(null, document.title, "/about/" + name + "/edit") - this.documentModal.load(name, false) - }, - - destroyDocument: function(e, name){ - e && e.preventDefault() - - var name = e ? $(e.currentTarget).data("name") : name - - this.confirmModal.confirm("Are you sure you want to delete " + name + "?", $.proxy(function(){ - this.documentModal.destroy(name, $.proxy(function(){ - this.alertModal.alert("Document deleted!", $.proxy(function(){ - window.location.href = "/about" - }, this)) - }, this)) - }, this)) - - // this.documentModal.destroy(name) - }, - -}) - |
