blob: 6939a3cef89b77b533e48517b4df6ffc1c33525a [file] [log] [blame]
Iftekharul Islam99d199f2017-03-24 15:28:25 -05001window.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 },
Iftekharul Islamcd789502017-04-19 14:37:55 -050014 'controller': ['$scope', '$location', 'dataService', function($scope, $location, dataService){
15 $scope.change = function(firstLevel){
16 $scope.firstLevel = firstLevel;
17 $location.path('/'+firstLevel);
18 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -050019 $scope.$watch('showNavigation', function(){
20 var paddingTop = 0;
Iftekharul Islamcd789502017-04-19 14:37:55 -050021 var urlRoot = $location.path().split("/")[1];
22 if(urlRoot != ""){
23 $scope.firstLevel = urlRoot;
24 }else{
25 $scope.firstLevel = 'overview';
26 }
27
Iftekharul Islam99d199f2017-03-24 15:28:25 -050028 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);