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.change = function(firstLevel){ 16 $scope.firstLevel = firstLevel; 17 $location.path('/'+firstLevel); 18 } 19 $scope.$watch('showNavigation', function(){ 20 var paddingTop = 0; 21 var urlRoot = $location.path().split("/")[1]; 22 if(urlRoot != ""){ 23 $scope.firstLevel = urlRoot; 24 }else{ 25 $scope.firstLevel = 'overview'; 26 } 27 28 if($scope.showNavigation){ 29 paddingTop = document.getElementById('header__wrapper').offsetHeight; 30 } 31 dataService.bodyStyle = {'padding-top': paddingTop + 'px'}; 32 $scope.navStyle = {'top': paddingTop + 'px'}; 33 }); 34 }] 35 }; 36 }); 37})(window.angular); 38