'use strict';

var angular = require('angular');
require('../modules');

angular
  .module('infoDisplay.directives')
  .directive('sinoTab', sinoTab);
  
/** @ngInject */
function sinoTab() {
  
  return {
    restrict: 'E',
    transclude: true,
    template: '<div class="sino-tab" ng-transclude ng-if="cache"></div><p ng-if="!cache"></p>',
    require: '^sinoTabs',
    scope: true,
    link: link
  }
  
  function link(scope, element, attrs, ctrl) {
    scope.cache = false;
    
    init();
    
    function init() {
      ctrl.addTab(new Tab(scope, attrs.name));
    };
  }
}

function Tab(scope, name) {
  this.scope = scope;
  this.name = name;
}