summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/ui')
-rw-r--r--public/assets/javascripts/ui/MasterView.js63
-rw-r--r--public/assets/javascripts/ui/ModalView.js11
-rw-r--r--public/assets/javascripts/ui/NewProjectModal.js (renamed from public/assets/javascripts/ui/CreateProjectModal.js)2
3 files changed, 55 insertions, 21 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()
},
diff --git a/public/assets/javascripts/ui/ModalView.js b/public/assets/javascripts/ui/ModalView.js
index 5c8e832..a34520f 100644
--- a/public/assets/javascripts/ui/ModalView.js
+++ b/public/assets/javascripts/ui/ModalView.js
@@ -1,7 +1,7 @@
var ModalView = View.extend({
events: {
- "click .close": 'hide',
+ "click .close": 'close',
},
show: function(){
@@ -14,5 +14,14 @@ var ModalView = View.extend({
// $(".mediaDrawer, .room1").removeClass("active editing");
this.$el.removeClass("active");
$("body").removeClass("noOverflow");
+ },
+
+ close: function(){
+ if (window.isModalView) {
+ window.location.pathname = "/"
+ }
+ else {
+ this.hide()
+ }
}
})
diff --git a/public/assets/javascripts/ui/CreateProjectModal.js b/public/assets/javascripts/ui/NewProjectModal.js
index 44c5a20..58dcb73 100644
--- a/public/assets/javascripts/ui/CreateProjectModal.js
+++ b/public/assets/javascripts/ui/NewProjectModal.js
@@ -1,6 +1,6 @@
-var CreateProjectModal = ModalView.extend({
+var NewProjectModal = ModalView.extend({
el: ".mediaDrawer.newProject",
action: "/project/new",