1window.angular && (function (angular) {
2    'use strict';
3
4    angular
5        .module('app.common.directives')
6        .directive('appNavigation', function () {
7            return {
8                'restrict': 'E',
9                'templateUrl': 'common/directives/app-navigation.html',
10                'scope': {
11                    'path': '=',
12                    'showNavigation': '='
13                },
14                'controller': ['$scope', '$location', 'dataService', function($scope, $location, dataService){
15                    $scope.showSubMenu = false;
16                    $scope.change = function(firstLevel){
17                        if(firstLevel != $scope.firstLevel) {
18                            $scope.firstLevel = firstLevel;
19                            $scope.showSubMenu = true;
20                        }else{
21                           $scope.showSubMenu = !$scope.showSubMenu;
22                        }
23                    };
24                    $scope.closeSubnav = function(){
25                        $scope.showSubMenu = false;
26                    };
27                    $scope.$watch('showNavigation', function(){
28                        var paddingTop = 0;
29                        var urlRoot = $location.path().split("/")[1];
30                        if(urlRoot != ""){
31                            $scope.firstLevel = urlRoot;
32                        }else{
33                            $scope.firstLevel = 'overview';
34                        }
35
36                        if($scope.showNavigation){
37                            paddingTop = document.getElementById('header__wrapper').offsetHeight;
38                        }
39                        dataService.bodyStyle = {'padding-top': paddingTop + 'px'};
40                        $scope.navStyle = {'top': paddingTop + 'px'};
41                    });
42                }]
43            };
44        });
45})(window.angular);
46