import {
  okOptions
} from '../../settings/ok';
import {
  viewCaseOptions
} from '../../settings/view-case';

export class IntroLookAroundController {
  constructor($http, $log, $state, toastr, globalVar, $scope, introService) {
    'ngInject';

    this.$http = $http;
    this.$log = $log;
    this.$state = $state;
    this.toastr = toastr;
    this.globalVar = globalVar;
    this.$scope = $scope;
    this.introService = introService;


    this.$onInit = this.onInit.bind(this);
    this.$onChanges = this.onChanges.bind(this);
  }

  onInit() {
  }

  onChanges(changes) {
    if (changes) {

    }
  }

  viewCase() {
    let url = this.globalVar.AUTH_URL + '#/home?showIntro=view-case';
    window.location.href = url;
    if (window.location.href === url) {
      let self = this;
      this.introService.showIntros(viewCaseOptions, function () {
        window.location.href = self.globalVar.AUTH_URL + '#/home';
      }, function () {
        angular.element('.introjs-tooltip').css({
          left: '',
          right: '15px'
        });
      });
    } else {
      window.location.href = url;
    }

    this.closeModal('viewCase');
  }

  dontNeed() {
    this.modalInstance.result.then(res => {
      if (res) {
        this.introService.showIntros(okOptions);
      }
    });

    this.closeModal('dontNeed');
  }

  closeModal(value) {
    return this.close({
      $value: value
    });
  }
}

export const introLookAroundComponent = {
  bindings: {
    // For uibModal
    resolve: '<',
    modalInstance: '<',
    close: '&',
    dismiss: '&'
  },
  templateUrl: 'app/modules/intros/components/intro-lookAround/intro-lookAround.html',
  controller: IntroLookAroundController
};