blob: 00c3ec74ce58710dba98add93b5ddf508668fa05 [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){
Iftekharul Islam685fe752017-05-05 09:17:54 -050015 $scope.showSubMenu = false;
Iftekharul Islamcd789502017-04-19 14:37:55 -050016 $scope.change = function(firstLevel){
Iftekharul Islam685fe752017-05-05 09:17:54 -050017 if(firstLevel != $scope.firstLevel) {
18 $scope.firstLevel = firstLevel;
19 $scope.showSubMenu = true;
20 }else{
21 $scope.showSubMenu = !$scope.showSubMenu;
22 }
Michael Davis272297b2017-04-24 12:11:53 -050023 };
24 $scope.closeSubnav = function(){
Iftekharul Islam685fe752017-05-05 09:17:54 -050025 $scope.showSubMenu = false;
Michael Davis272297b2017-04-24 12:11:53 -050026 };
Iftekharul Islam99d199f2017-03-24 15:28:25 -050027 $scope.$watch('showNavigation', function(){
28 var paddingTop = 0;
Iftekharul Islam685fe752017-05-05 09:17:54 -050029 var urlRoot = $location.path().split("/")[1];
30 if(urlRoot != ""){
31 $scope.firstLevel = urlRoot;
32 }else{
33 $scope.firstLevel = 'overview';
34 }
Iftekharul Islamcd789502017-04-19 14:37:55 -050035
Iftekharul Islam99d199f2017-03-24 15:28:25 -050036 if($scope.showNavigation){
37 paddingTop = document.getElementById('header__wrapper').offsetHeight;
38 }
39 dataService.bodyStyle = {'padding-top': paddingTop + 'px'};
40 $scope.navStyle = {'top': paddingTop + 'px'};
41 });
42 }]
43 };
44 });
45})(window.angular);