mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-07 11:10:16 +01:00
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
(function() {
|
|
|
|
'use strict';
|
|
|
|
angular
|
|
.module('harbor.layout.navigation')
|
|
.directive('navigationAdminOptions', navigationAdminOptions);
|
|
|
|
NavigationAdminOptions.$inject = ['$location'];
|
|
|
|
function NavigationAdminOptions($location) {
|
|
var vm = this;
|
|
vm.path = $location.path();
|
|
}
|
|
|
|
function navigationAdminOptions() {
|
|
var directive = {
|
|
'restrict': 'E',
|
|
'templateUrl': '/static/resources/js/layout/navigation/navigation-admin-options.directive.html',
|
|
'scope': {
|
|
'target': '='
|
|
},
|
|
'link': link,
|
|
'controller': NavigationAdminOptions,
|
|
'controllerAs': 'vm',
|
|
'bindToController': true
|
|
};
|
|
return directive;
|
|
|
|
function link(scope, element, attrs, ctrl) {
|
|
var visited = ctrl.path.substring(1);
|
|
console.log('visited:' + visited);
|
|
|
|
if(visited) {
|
|
element.find('a[tag="' + visited + '"]').addClass('active');
|
|
}else{
|
|
element.find('a:first').addClass('active');
|
|
}
|
|
|
|
element.find('a').on('click', click);
|
|
|
|
function click(event) {
|
|
element.find('a').removeClass('active');
|
|
$(event.target).addClass('active');
|
|
ctrl.target = $(this).attr('tag');
|
|
scope.$apply();
|
|
}
|
|
}
|
|
}
|
|
|
|
})(); |