// Generated by CoffeeScript 1.6.3
var __hasProp = {}.hasOwnProperty,
  __extends = 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; };

define(["backbone"], function(Backbone) {
  var SideBarView, _ref;
  return SideBarView = (function(_super) {
    __extends(SideBarView, _super);

    function SideBarView() {
      _ref = SideBarView.__super__.constructor.apply(this, arguments);
      return _ref;
    }

    SideBarView.prototype.loadValidators = function() {
      var metrics;
      metrics = [
        ['#aws_access_key_id', 'presence', 'Cannot be empty'], ['#aws_secret_access_key', 'presence', 'Cannot be empty'], ['#table_name', 'presence', 'Cannot be empty'], ['#database_url', 'presence', 'Cannot be empty'], ['#host', 'presence', 'Cannot be empty'], ['#port', 'presence', 'Cannot be empty'], [
          '#port', (function(port) {
            var is_available;
            is_available = null;
            $.ajax({
              async: false,
              url: '/is_port_available',
              type: "POST",
              data: JSON.stringify({
                port: port
              }),
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function(data) {
                if (data.is_available === 1) {
                  return is_available = true;
                } else {
                  return is_available = false;
                }
              }
            });
            return is_available;
          }), 'Port unavailable'
        ], ['#port', 'between-num:1024:65535', 'Must be between 1024 and 65535'], ['#port', 'presence', 'Cannot be empty'], ['#cutoff_time', 'presence', 'Cannot be empty'], [
          '#cutoff_time', (function(x) {
            return x > 0;
          }), 'Must be positive'
        ], ['#title', 'presence', 'Cannot be empty'], ['#description', 'presence', 'Cannot be empty'], ['#keywords', 'presence', 'Cannot be empty'], ['#question_url', 'presence', 'Cannot be empty'], ['#max_assignments', 'presence', 'Cannot be empty'], ['#max_assignments', 'integer', 'Must be a whole number'], [
          '#max_assignments', (function(x) {
            return x > 0;
          }), 'Must be non-negative'
        ], [
          '#hit_lifetime', (function(x) {
            return x > 0;
          }), 'Must be positive'
        ], ['#hit_lifetime', 'presence', 'Cannot be empty'], ['#hit_lifetime', 'presence', 'Cannot be empty'], ['#reward', 'presence', 'Cannot be empty'], [
          '#reward', (function(x) {
            return x >= 0;
          }), 'Must be non-negative'
        ], ['#duration', 'presence', 'Cannot be empty'], [
          '#duration', (function(x) {
            return x > 0;
          }), 'Must be positive'
        ], ['#approve_requirement', 'between-num:0:100', 'Must be between 0 and 100'], ['#approve_requirement', 'presence', 'Cannot be empty']
      ];
      return $("#myform").nod(metrics);
    };

    return SideBarView;

  })(Backbone.View);
});
