// Generated by CoffeeScript 1.4.0
(function() {
  var Notification, Notificator,
    __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  Notification = (function() {

    function Notification(type, text, timeout, notificator, position) {
      this.type = type;
      this.text = text;
      this.timeout = timeout;
      this.notificator = notificator;
      this.position = position;
      this.moveUp = __bind(this.moveUp, this);

      this.remove = __bind(this.remove, this);

      this.dom = $("<div class=\"notification " + this.type + "\">\n    " + this.text + "\n</div>");
      this.active = true;
      this.position = 0;
      this.dom.css({
        top: this.position + 'px',
        left: '300px'
      });
      this.dom.animate({
        left: '0px'
      }, 500, 'swing');
      setTimeout(this.remove, this.timeout);
    }

    Notification.prototype.remove = function() {
      var _this = this;
      return this.dom.fadeTo(500, 0, function() {
        _this.notificator.notifications.pop(_this);
        return _this.dom.remove();
      });
    };

    Notification.prototype.moveUp = function(dy) {
      this.position -= dy;
      return this.dom.animate({
        top: this.position + 'px'
      }, 500, 'swing');
    };

    return Notification;

  })();

  Notificator = (function() {

    function Notificator() {
      this.notifications = [];
    }

    Notificator.prototype.notify = function(type, text, timeout) {
      var notification, _fn, _i, _len, _ref,
        _this = this;
      if (timeout == null) {
        timeout = 7000;
      }
      _ref = this.notifications;
      _fn = function(notification) {
        return notification.moveUp(-50);
      };
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        notification = _ref[_i];
        _fn(notification);
      }
      notification = new Notification(type, text, timeout, this, 0);
      this.notifications.push(notification);
      return $('#notifications').append(notification.dom);
    };

    return Notificator;

  })();

  window.Notificator = new Notificator();

}).call(this);
