diff options
Diffstat (limited to 'public/assets/javascripts/ui')
| -rw-r--r-- | public/assets/javascripts/ui/CreateProjectModal.js | 50 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/EditProfileModal.js | 49 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/EditProjectModal.js | 49 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/MasterView.js | 21 |
4 files changed, 169 insertions, 0 deletions
diff --git a/public/assets/javascripts/ui/CreateProjectModal.js b/public/assets/javascripts/ui/CreateProjectModal.js new file mode 100644 index 0000000..44c5a20 --- /dev/null +++ b/public/assets/javascripts/ui/CreateProjectModal.js @@ -0,0 +1,50 @@ + + +var CreateProjectModal = ModalView.extend({ + el: ".mediaDrawer.newProject", + action: "/project/new", + + events: { + "submit form": "submit" + }, + + initialize: function(){ + this.$form = this.$("form") + this.$errors = this.$(".errors") + this.$errorList = this.$(".errorList") + }, + + reset: function(){ + this.$("input").not("[type='submit']").not("[type='hidden']").val("") + }, + + load: function(){ + this.reset() + this.show() + }, + + submit: function(e){ + e.preventDefault() + + this.$errors.hide(); + this.$errorList.empty() + + var fields = this.$form.serializeArray() + + var request = $.post(this.action, $.param(fields)); + request.done($.proxy(function (response) { + if (response.error) { + this.$errors.show(); + for (var key in response.error.errors) { + this.$errorList.append('<div>' + response.error.errors[key].message + '</div>'); + } + return + } + else { + window.location.href = "/profile" + } + }, this)); + } + +}) + diff --git a/public/assets/javascripts/ui/EditProfileModal.js b/public/assets/javascripts/ui/EditProfileModal.js new file mode 100644 index 0000000..de8a8be --- /dev/null +++ b/public/assets/javascripts/ui/EditProfileModal.js @@ -0,0 +1,49 @@ + +var EditProfileModal = ModalView.extend({ + el: ".mediaDrawer.editProfile", + action: "/project/edit", + + events: { + "submit form": "submit" + }, + + initialize: function(){ + this.$form = this.$("form") + this.$errors = this.$(".errors") + this.$errorList = this.$(".errorList") + }, + + reset: function(){ + this.$("input").not("[type='submit']").not("[type='hidden']").val("") + }, + + load: function(){ + this.reset() + this.show() + }, + + submit: function(e){ + e.preventDefault() + + this.$errors.hide(); + this.$errorList.empty() + + var fields = this.$form.serializeArray() + + var request = $.post(this.action, $.param(fields)); + request.done($.proxy(function (response) { + if (response.error) { + this.$errors.show(); + for (var key in response.error.errors) { + this.$errorList.append('<div>' + response.error.errors[key].message + '</div>'); + } + return + } + else { + window.location.href = "/profile" + } + }, this)); + } + +}) + diff --git a/public/assets/javascripts/ui/EditProjectModal.js b/public/assets/javascripts/ui/EditProjectModal.js new file mode 100644 index 0000000..356d8b7 --- /dev/null +++ b/public/assets/javascripts/ui/EditProjectModal.js @@ -0,0 +1,49 @@ + +var EditProjectModal = ModalView.extend({ + el: ".mediaDrawer.editProject", + action: "/project/edit", + + events: { + "submit form": "submit" + }, + + initialize: function(){ + this.$form = this.$("form") + this.$errors = this.$(".errors") + this.$errorList = this.$(".errorList") + }, + + reset: function(){ + this.$("input").not("[type='submit']").not("[type='hidden']").val("") + }, + + load: function(){ + this.reset() + this.show() + }, + + submit: function(e){ + e.preventDefault() + + this.$errors.hide(); + this.$errorList.empty() + + var fields = this.$form.serializeArray() + + var request = $.post(this.action, $.param(fields)); + request.done($.proxy(function (response) { + if (response.error) { + this.$errors.show(); + for (var key in response.error.errors) { + this.$errorList.append('<div>' + response.error.errors[key].message + '</div>'); + } + return + } + else { + window.location.href = "/profile" + } + }, this)); + } + +}) + diff --git a/public/assets/javascripts/ui/MasterView.js b/public/assets/javascripts/ui/MasterView.js index 9657c56..e99777e 100644 --- a/public/assets/javascripts/ui/MasterView.js +++ b/public/assets/javascripts/ui/MasterView.js @@ -5,11 +5,17 @@ var MasterView = View.extend({ 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', }, initialize: function(){ this.signUpModal = new SignUpModal() this.signInModal = new SignInModal() + this.createProjectModal = new CreateProjectModal() + this.editProjectModal = new EditProjectModal() + this.editProfileModal = new EditProfileModal() $("body").removeClass("loading") // app.launch() @@ -25,6 +31,21 @@ var MasterView = View.extend({ e.preventDefault() this.signInModal.load() }, + + showCreateProjectModal: function(e){ + e.preventDefault() + this.createProjectModal.load() + }, + + showEditProjectModal: function(e){ + e.preventDefault() + this.editProjectModal.load() + }, + + showEditProfileModal: function(e){ + e.preventDefault() + this.editProfileModal.load() + }, }) |
