Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 1 | window.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 Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame^] | 14 | 'controller': ['$scope', '$location', 'dataService', function($scope, $location, dataService){ |
| 15 | $scope.change = function(firstLevel){ |
| 16 | $scope.firstLevel = firstLevel; |
| 17 | $location.path('/'+firstLevel); |
| 18 | } |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 19 | $scope.$watch('showNavigation', function(){ |
| 20 | var paddingTop = 0; |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame^] | 21 | var urlRoot = $location.path().split("/")[1]; |
| 22 | if(urlRoot != ""){ |
| 23 | $scope.firstLevel = urlRoot; |
| 24 | }else{ |
| 25 | $scope.firstLevel = 'overview'; |
| 26 | } |
| 27 | |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 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); |