summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/vendor/ModalFormView.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-06-10 12:00:24 -0400
committerJules Laplace <jules@okfoc.us>2014-06-10 12:00:24 -0400
commit9fb0fe9b7ef614d2248b00ea2b964205f3453f41 (patch)
tree953fd956e1c6b3d641226d7ac36cc749ced92504 /public/assets/javascripts/vendor/ModalFormView.js
parent3f8e4223cc57bc3fd461881e3d6e9eb331bf4dc5 (diff)
split up builder functionality
Diffstat (limited to 'public/assets/javascripts/vendor/ModalFormView.js')
-rw-r--r--public/assets/javascripts/vendor/ModalFormView.js96
1 files changed, 0 insertions, 96 deletions
diff --git a/public/assets/javascripts/vendor/ModalFormView.js b/public/assets/javascripts/vendor/ModalFormView.js
deleted file mode 100644
index d084031..0000000
--- a/public/assets/javascripts/vendor/ModalFormView.js
+++ /dev/null
@@ -1,96 +0,0 @@
-
-var ModalFormView = ModalView.extend({
-
- method: "post",
-
- events: {
- "submit form": "submit"
- },
-
- initialize: function(){
- this.$form = this.$("form")
- this.$errors = this.$(".errors")
- this.$errorList = this.$(".errorList")
- },
-
- reset: function(){
- this.$("input,textarea").not("[type='submit']").not("[type='hidden']").val("")
- },
-
- load: function(){
- this.reset()
- this.show()
- },
-
- showErrors: function(errors){
- if (errors && errors.length) {
- this.$errorList.empty();
- for (var i in errors) {
- this.$errorList.append('<div>' + errors[i] + '</div>');
- }
- this.$errors.css("opacity", 1.0);
- setTimeout($.proxy(function(){
- this.$errors.show().css("opacity", 1.0);
- }, this), 200)
- }
- },
-
- serialize: function(){
- var fd = new FormData()
-
- this.$("input[name], select[name], textarea[name]").each( function(){
- if (this.type == "file") {
- if (this.files.length > 0) {
- fd.append(this.name, this.files[0]);
- }
- }
- else if (this.type == "password") {
- if (this.value.length > 0) {
- fd.append(this.name, SHA1.hex('lol$' + this.value + '$vvalls'))
- }
- }
- else {
- fd.append(this.name, this.value);
- }
- });
-
- return fd
- },
-
- submit: function(e){
- e.preventDefault()
-
- this.$errors.hide().css("opacity", 0.0);
-
- if (this.validate) {
- var errors = this.validate()
- if (errors && errors.length) {
- this.showErrors(errors)
- return
- }
- }
-
- var request = $.ajax({
- url: this.action,
- type: this.method,
- data: this.serialize(),
- dataType: "json",
- processData: false,
- contentType: false,
- });
- request.done($.proxy(function (response) {
- if (response.error) {
- var errors = []
- for (var key in response.error.errors) {
- errors.push(response.error.errors[key].message);
- }
- this.showErrors(errors)
- return
- }
- else {
- this.success && this.success(response)
- }
- }, this));
- }
-
-})