var angular = require('angular');
require('../modules');
require('ngIonic');
require('../../../commons/services/Timer');

var module = angular.module('linker.directives.linkernav');

module.directive('linkerNavInfo', function(Timer) {
  return {
    restrict: 'E',
    template: '<div class="linker-nav-info" ng-if="show"><span>{{text}}</span></div>',
    scope: true,
    link: function(scope) {
      var hideTimer = null;
      scope.text = null;
      scope.show = false;
      scope.$on('linkernav.infochange', function($event, nav) {
        Timer.clear(hideTimer);
        scope.$evalAsync(function() {
          scope.text = nav;
          scope.show = true;
          hideTimer = Timer.delay(function() {
            scope.show = false;
          }, 2500);
        });
      });
    }
  };
});
