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.dataService = dataService; 16 $scope.showSubMenu = false; 17 $scope.change = function(firstLevel){ 18 if(firstLevel != $scope.firstLevel) { 19 $scope.firstLevel = firstLevel; 20 $scope.showSubMenu = true; 21 }else{ 22 $scope.showSubMenu = !$scope.showSubMenu; 23 } 24 }; 25 $scope.closeSubnav = function(){ 26 $scope.showSubMenu = false; 27 }; 28 $scope.$watch('path', function(){ 29 var urlRoot = $location.path().split("/")[1]; 30 if(urlRoot != ""){ 31 $scope.firstLevel = urlRoot; 32 }else{ 33 $scope.firstLevel = 'overview'; 34 } 35 $scope.showSubMenu = false; 36 }); 37 $scope.$watch('showNavigation', function(){ 38 var paddingTop = 0; 39 var urlRoot = $location.path().split("/")[1]; 40 if(urlRoot != ""){ 41 $scope.firstLevel = urlRoot; 42 }else{ 43 $scope.firstLevel = 'overview'; 44 } 45 46 if($scope.showNavigation){ 47 paddingTop = document.getElementById('header__wrapper').offsetHeight; 48 } 49 dataService.bodyStyle = {'padding-top': paddingTop + 'px'}; 50 $scope.navStyle = {'top': paddingTop + 'px'}; 51 }); 52 }] 53 }; 54 }); 55})(window.angular); 56