(function() {
  var Flash, Shelf, Sil, Tile, View;
  var __hasProp = Object.prototype.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;
  }, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  View = (function() {
    View.prototype.html = "<div></div>";
    View.prototype.target = "body";
    View.prototype.attr = {};
    View.prototype.css = {};
    View.prototype.items = [];
    function View(o) {
      $.extend(this, o || {});
    }
    View.prototype.draw = function() {
      var item, _i, _len, _ref, _ref2, _results;
      if (this.$ != null) {
        return this.$.show();
      } else {
        if ((_ref = this.$) == null) {
          this.$ = $(this.html).appendTo(this.target).css(this.css).attr(this.attr);
        }
        if (this.click != null) {
          this.$.click(this.click);
        }
        if (this.text != null) {
          this.$.text(this.text);
        }
        if (this["class"] != null) {
          this.$.addClass(this["class"]);
        }
        _ref2 = this.items;
        _results = [];
        for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
          item = _ref2[_i];
          item.target = this.$;
          item.draw();
          _results.push(item.parent = this);
        }
        return _results;
      }
    };
    return View;
  })();
  Tile = (function() {
    __extends(Tile, View);
    function Tile() {
      Tile.__super__.constructor.apply(this, arguments);
    }
    Tile.prototype["class"] = "sil-tile";
    Tile.prototype.html = "<span></span>";
    return Tile;
  })();
  Flash = (function() {
    __extends(Flash, View);
    function Flash() {
      Flash.__super__.constructor.apply(this, arguments);
    }
    Flash.prototype["class"] = "sil-flash";
    Flash.prototype.css = {
      display: 'none'
    };
    Flash.prototype.msg = function(msg) {
      return this.$.text(msg).show().fadeTo(3000, 0);
    };
    return Flash;
  })();
  Shelf = (function() {
    __extends(Shelf, View);
    function Shelf() {
      this.items = [
        new Tile({
          text: 'logout',
          click: __bind(function() {
            return this.parent.logout();
          }, this)
        }), new Tile({
          text: 'edit'
        }), new Tile({
          text: 'code'
        })
      ];
      Shelf.__super__.constructor.call(this);
    }
    Shelf.prototype["class"] = "sil-shelf";
    return Shelf;
  })();
  Sil = (function() {
    __extends(Sil, View);
    function Sil() {
      this.shelf = new Shelf();
      this.flash = new Flash();
      this.items = [this.shelf, this.flash];
      Sil.__super__.constructor.call(this);
    }
    Sil.prototype.attr = {
      id: 'sil'
    };
    Sil.prototype.logout = function() {
      return $.get('/Sil/logout', __bind(function(res) {
        if (res.success) {
          this.shelf.$.remove();
        }
        return this.flash.msg("You have now logged out.");
      }, this));
    };
    return Sil;
  })();
  $(function() {
    var sill;
    sill = new Sil();
    return sill.draw();
  });
}).call(this);

