text: // Generated by CoffeeScript 1.10.0
  (function() {
    var LoaderWidget,
      bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  
    LoaderWidget = (function() {
      LoaderWidget.prototype.opts = {
        color: '#aaaaaa',
        width: 4
      };
  
      function LoaderWidget() {
        this.stop = bind(this.stop, this);
        this.start = bind(this.start, this);
        this.message = bind(this.message, this);
        this.onresize = bind(this.onresize, this);
        this.window = $(window);
        this.overlay = $('<div>').width(this.window.width()).height(this.window.height()).hide().css({
          position: 'absolute',
          top: 0,
          left: 0,
          'z-index': 10000,
          background: 'rgba(0, 0, 0, 0.7)',
          'text-align': 'center'
        }).appendTo(document.body).on('selectstart', (function() {
          return false;
        }));
        this.box = $('<div>').width(300).height(200).appendTo(this.overlay);
        this.canvas = $('<div>').height(100).appendTo(this.box);
        this.text = $('<div>').css({
          color: '#ddd',
          'font-size': '12px',
          cursor: 'default'
        }).appendTo(this.box);
        this.onresize();
        this.window.resize(this.onresize);
      }
  
      LoaderWidget.prototype.onresize = function() {
        var height, ref, width;
        ref = [this.window.width(), this.window.height()], width = ref[0], height = ref[1];
        this.box.css({
          position: 'absolute',
          top: (height - 200) / 2,
          left: (width - 300) / 2
        });
        return this.overlay.width(width).height(height);
      };
  
      LoaderWidget.prototype.message = function(msg, callback) {
        if (msg != null) {
          this.text.html(msg);
        }
        if (this.isActive) {
          return typeof callback === "function" ? callback() : void 0;
        } else {
          return this.start(callback);
        }
      };
  
      LoaderWidget.prototype.start = function(callback) {
        this.overlay.fadeIn((function(_this) {
          return function() {
            return typeof callback === "function" ? callback() : void 0;
          };
        })(this));
        if (this.spin) {
          this.spin.spin(this.canvas[0]);
        } else {
          this.spin = new Spinner(this.opts);
          this.spin.spin(this.canvas[0]);
        }
        return this.isActive = true;
      };
  
      LoaderWidget.prototype.stop = function(callback) {
        return this.overlay.fadeOut('slow', (function(_this) {
          return function() {
            var ref;
            if ((ref = _this.spin) != null) {
              ref.stop();
            }
            _this.isActive = false;
            return typeof callback === "function" ? callback() : void 0;
          };
        })(this));
      };
  
      return LoaderWidget;
  
    })();
  
    this.LoaderWidget = LoaderWidget;
  
  }).call(this);
  