text: // Generated by CoffeeScript 1.11.1
  (function() {
    var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
      extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
      hasProp = {}.hasOwnProperty;
  
    $((function(_this) {
      return function() {
        return _this.ProjectFormView = (function(superClass) {
          extend(ProjectFormView, superClass);
  
          function ProjectFormView() {
            _this.on_image_upload_change = bind(_this.on_image_upload_change, this);
            _this.on_description_change = bind(_this.on_description_change, this);
            _this.on_delete = bind(_this.on_delete, this);
            _this.on_cancel = bind(_this.on_cancel, this);
            _this.on_revert = bind(_this.on_revert, this);
            _this.on_save = bind(_this.on_save, this);
            _this.on_create = bind(_this.on_create, this);
            _this.display_png = bind(_this.display_png, this);
            _this.render = bind(_this.render, this);
            return ProjectFormView.__super__.constructor.apply(this, arguments);
          }
  
          ProjectFormView.prototype.events = {
            'click #create': 'on_create',
            'click #save': 'on_save',
            'click #revert': 'on_revert',
            'click #cancel': 'on_cancel',
            'click #delete': 'on_delete',
            'change #project_description': 'on_description_change',
            'change #image_upload': 'on_image_upload_change'
          };
  
          ProjectFormView.prototype.template = _.template($('#project_form_template').html());
  
          ProjectFormView.prototype.render = function() {
            this.$el.html(this.template(this.model.attributes));
            if (this.model.attributes.image) {
              this.display_png(this.model.attributes.image);
            }
            if (this.model.isNew()) {
              this.$el.find('#save, #delete, #revert').hide();
            } else {
              this.$el.find('#create, #cancel').hide();
            }
            return this;
          };
  
          ProjectFormView.prototype.display_png = function(data) {
            return this.$el.find('#project_image').attr('src', 'data:image/png;base64,' + data);
          };
  
          ProjectFormView.prototype.on_create = function() {
            return this.model.save(this.model.attributes, {
              wait: true,
              success: function() {
                return app.navigate('project_list', {
                  trigger: true
                });
              }
            });
          };
  
          ProjectFormView.prototype.on_save = function() {
            return this.model.save(this.model.changedAttributes(), {
              wait: true,
              success: (function(_this) {
                return function() {
                  return app.navigate('project_list', {
                    trigger: true
                  });
                };
              })(this)
            });
          };
  
          ProjectFormView.prototype.on_revert = function() {
            return app.project_view(this.model.get('id'));
          };
  
          ProjectFormView.prototype.on_cancel = function() {
            return app.navigate('project_list', {
              trigger: true
            });
          };
  
          ProjectFormView.prototype.on_delete = function() {
            return this.model.destroy({
              wait: true,
              success: function() {
                return app.navigate('project_list', {
                  trigger: true
                });
              }
            });
          };
  
          ProjectFormView.prototype.on_description_change = function(event) {
            return this.model.set({
              'description': $(event.target).val()
            });
          };
  
          ProjectFormView.prototype.on_image_upload_change = function(event) {
            var fileReader;
            fileReader = new FileReader;
            fileReader.onload = (function(_this) {
              return function(event) {
                _this.model.set({
                  image: btoa(event.target.result)
                });
                return _this.display_png(_this.model.get('image'));
              };
            })(this);
            return fileReader.readAsBinaryString(event.target.files[0]);
          };
  
          return ProjectFormView;
  
        })(Backbone.View);
      };
    })(this));
  
  }).call(this);
  