// Generated by CoffeeScript 1.8.0
(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __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(['list/listAndSelection'], function(List) {
    var SimpleList;
    return SimpleList = (function(_super) {
      __extends(SimpleList, _super);

      function SimpleList(list, skel) {
        this.annuler = __bind(this.annuler, this);
        this.valider = __bind(this.valider, this);
        this.creer = __bind(this.creer, this);
        this.showListCallback = __bind(this.showListCallback, this);
        SimpleList.__super__.constructor.call(this, list, null, skel);
      }

      SimpleList.prototype.showListCallback = function() {
        var annuler, valider;
        SimpleList.__super__.showListCallback.apply(this, arguments);
        this.creerBtn = this.list.querySelector("#creer");
        if (this.creerBtn != null) {
          this.creerBtn.addEventListener('click', this.creer);
        }
        if ((this.creerBtn != null) && (this.sNewCommand == null)) {
          alert('New command (sNewCommand) not defined');
        }
        this.form = this.list.querySelector("#holder");
        if (this.form != null) {
          valider = this.form.querySelector("#valider");
        }
        if (valider != null) {
          valider.addEventListener('click', this.valider);
        }
        if (this.form != null) {
          annuler = this.form.querySelector("#annuler");
        }
        if (annuler != null) {
          annuler.addEventListener('click', this.annuler);
        }
        if (this.form != null) {
          return this.stencilHolderNom = this.form.querySelector("#stencilHolderNom");
        }
      };

      SimpleList.prototype.creer = function(evt) {
        var bocall;
        if (evt) {
          evt.preventDefault();
        }
        bocall = new BOCall;
        bocall.done = (function(_this) {
          return function() {
            var bo;
            _this.commandPath = bocall.commandPath;
            bo = new BOCall;
            bo.appendBOParam("ap1", "U3RlbmNpbEhvbGRlcg==");
            bo.done = function() {
              return _this.stencilHolderNom.innerHTML = bo.responseText;
            };
            bo.postFacet(_this.commandPath, "<input id=\"inputNom\" data-value=\"Nom\" name=\"s_\"/>", "dom5");
            _this.creerBtn.classList.add("hidden");
            return _this.form.classList.remove("hidden");
          };
        })(this);
        return bocall.applyCommand(this.path, this.sNewCommand);
      };

      SimpleList.prototype.valider = function(evt) {
        var bocall, inputNom;
        if (evt) {
          evt.preventDefault();
        }
        bocall = new BOCall;
        inputNom = this.form.querySelector('#inputNom');
        bocall.appendBOParam(inputNom.getAttribute('name'), inputNom.value);
        bocall.done = (function(_this) {
          return function() {
            _this.creerBtn.classList.remove("hidden");
            _this.form.classList.add("hidden");
            return _this.showList();
          };
        })(this);
        return bocall.applyCommand(this.commandPath, "NextStep");
      };

      SimpleList.prototype.annuler = function(evt) {
        var bocall;
        if (evt) {
          evt.preventDefault();
        }
        bocall = new BOCall;
        bocall.applyCommand(this.commandPath, "Cancel");
        return bocall.done = (function(_this) {
          return function() {
            _this.creerBtn.classList.remove("hidden");
            return _this.form.classList.add("hidden");
          };
        })(this);
      };

      return SimpleList;

    })(List);
  });

}).call(this);

//# sourceMappingURL=simpleList.js.map
