1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
window.angular && (function(angular) {
'use strict';
angular.module('app.common.directives')
.directive('appNavigation', function() {
return {
'restrict': 'E',
'template': require('./app-navigation.html'),
'scope': {'path': '=', 'showNavigation': '='},
'controller': [
'$scope', '$location', 'dataService',
function($scope, $location, dataService) {
$scope.showHealthMenu = false;
$scope.showControlMenu = false;
$scope.showConfigMenu = false;
$scope.showAccessMenu = false;
$scope.dataService = dataService;
$scope.change = function(firstLevel) {
switch (firstLevel) {
case 'server-health':
$scope.showHealthMenu = !$scope.showHealthMenu;
break;
case 'server-control':
$scope.showControlMenu = !$scope.showControlMenu;
break;
case 'configuration':
$scope.showConfigMenu = !$scope.showConfigMenu;
break;
case 'access-control':
$scope.showAccessMenu = !$scope.showAccessMenu;
break;
case 'overview':
$location.url('/overview/server');
break;
};
};
$scope.$watch('path', function() {
var urlRoot = $location.path().split('/')[1];
if (urlRoot != '') {
$scope.firstLevel = urlRoot;
} else {
$scope.firstLevel = 'overview';
}
$scope.showSubMenu = true;
});
$scope.$watch('showNavigation', function() {
var urlRoot = $location.path().split('/')[1];
if (urlRoot != '') {
$scope.firstLevel = urlRoot;
} else {
$scope.firstLevel = 'overview';
}
});
}
],
link: function(scope, element, attributes) {
var rawNavElement = angular.element(element)[0];
angular.element(window.document).bind('click', function(event) {
if (rawNavElement.contains(event.target)) return;
if (scope.showSubMenu) {
scope.$apply(function() {
scope.showSubMenu = true;
});
}
});
}
};
});
})(window.angular);
|