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; |
Michael Davis | 272297b | 2017-04-24 12:11:53 -0500 | [diff] [blame^] | 17 | //$location.path('/'+firstLevel); |
| 18 | }; |
| 19 | $scope.closeSubnav = function(){ |
| 20 | $scope.firstLevel = ''; |
| 21 | }; |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 22 | $scope.$watch('showNavigation', function(){ |
| 23 | var paddingTop = 0; |
Michael Davis | 272297b | 2017-04-24 12:11:53 -0500 | [diff] [blame^] | 24 | // var urlRoot = $location.path().split("/")[1]; |
| 25 | // if(urlRoot != ""){ |
| 26 | // $scope.firstLevel = urlRoot; |
| 27 | // }else{ |
| 28 | // $scope.firstLevel = 'overview'; |
| 29 | // } |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 30 | |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 31 | if($scope.showNavigation){ |
| 32 | paddingTop = document.getElementById('header__wrapper').offsetHeight; |
| 33 | } |
| 34 | dataService.bodyStyle = {'padding-top': paddingTop + 'px'}; |
| 35 | $scope.navStyle = {'top': paddingTop + 'px'}; |
| 36 | }); |
| 37 | }] |
| 38 | }; |
| 39 | }); |
| 40 | })(window.angular); |