mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-02 15:14:09 +01:00
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
(function() {
|
|
|
|
'use strict';
|
|
|
|
angular
|
|
.module('harbor.layout.navigation')
|
|
.directive('navigationHeader', navigationHeader);
|
|
|
|
NavigationHeaderController.$inject = ['$window'];
|
|
|
|
function NavigationHeaderController($window) {
|
|
var vm = this;
|
|
vm.url = $window.location.pathname;
|
|
}
|
|
|
|
function navigationHeader() {
|
|
var directive = {
|
|
restrict: 'E',
|
|
templateUrl: '/static/ng/resources/js/layout/navigation/navigation-header.directive.html',
|
|
link: link,
|
|
replace: true,
|
|
controller: NavigationHeaderController,
|
|
controllerAs: 'vm',
|
|
bindToController: true
|
|
}
|
|
|
|
return directive;
|
|
|
|
|
|
function link(scope, element, attrs, ctrl) {
|
|
|
|
element.find('a').removeClass('active');
|
|
|
|
var visited = ctrl.url;
|
|
if (visited != "/") {
|
|
element.find('a[href="' + visited + '"]').addClass('active');
|
|
}
|
|
|
|
element.on('click', click);
|
|
|
|
function click(event) {
|
|
element.find('a').removeClass('active');
|
|
$(event.target).not('span').addClass('active');
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})(); |