{"size": 3002, "ext": "js", "max_stars_repo_path": "Resources/ui/common/IntroScreen.js", "max_stars_repo_name": "irwansyahwii/Elements", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Resources/ui/common/IntroScreen.js", "max_issues_repo_name": "irwansyahwii/Elements", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Resources/ui/common/IntroScreen.js", "max_forks_repo_name": "irwansyahwii/Elements", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.145631068, "max_line_length": 85, "alphanum_fraction": 0.5942704863}
// Generated by CoffeeScript 1.9.2
(function() {
  var DELAY_BETWEEN_IMAGES, FADEOUT_DURATION, IntroScreen,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  DELAY_BETWEEN_IMAGES = 3000;

  FADEOUT_DURATION = 3000;

  IntroScreen = (function() {
    function IntroScreen() {
      this.play = bind(this.play, this);
      this.rotateImages = bind(this.rotateImages, this);
      this.onMainViewClicked = bind(this.onMainViewClicked, this);
      this.raiseOnExit = bind(this.raiseOnExit, this);
      var i, j, opacity;
      this.view = Ti.UI.createView();
      this.images = [];
      this.image_views = [];
      for (i = j = 1; j <= 5; i = ++j) {
        this.images.push("Intro-Content" + i + ".png");
        opacity = 0;
        if (i === 1) {
          opacity = 1;
        }
        this.image_view = Ti.UI.createImageView({
          image: this.images[i - 1],
          width: 2048 / 2,
          height: 1536 / 2,
          left: 0,
          top: 0,
          opacity: opacity
        });
        this.image_views.push(this.image_view);
        this.view.add(this.image_view);
      }
      this.view.addEventListener("click", this.onMainViewClicked);
      this.onExit = null;
      this.current_image_index = 0;
      this.previous_image_index = 0;
      this.stop_animation = false;
    }

    IntroScreen.prototype.raiseOnExit = function() {
      if (this.onExit !== null) {
        return this.onExit();
      }
    };

    IntroScreen.prototype.onMainViewClicked = function() {
      this.stop_animation = true;
      this.view.getParent().remove(this.view);
      return this.raiseOnExit();
    };

    IntroScreen.prototype.rotateImages = function() {
      var current_image_view, prev_image;
      if (this.stop_animation) {
        return;
      }
      this.current_image_index++;
      if (this.current_image_index >= this.images.length) {
        this.current_image_index = 0;
      }
      prev_image = this.image_views[this.previous_image_index];
      prev_image.animate({
        curve: Ti.UI.ANIMATION_CURVE_EASE_OUT,
        opacity: 0,
        duration: FADEOUT_DURATION
      }, (function(_this) {
        return function() {};
      })(this));
      current_image_view = this.image_views[this.current_image_index];
      this.previous_image_index = this.current_image_index;
      return current_image_view.animate({
        curve: Ti.UI.ANIMATION_CURVE_EASE_OUT,
        opacity: 1,
        duration: FADEOUT_DURATION
      }, (function(_this) {
        return function() {
          return setTimeout(function() {
            return _this.rotateImages();
          }, DELAY_BETWEEN_IMAGES);
        };
      })(this));
    };

    IntroScreen.prototype.play = function() {
      return setTimeout((function(_this) {
        return function() {
          return _this.rotateImages();
        };
      })(this), DELAY_BETWEEN_IMAGES);
    };

    return IntroScreen;

  })();

  module.exports = IntroScreen;

}).call(this);
