2016-04-19 11:58:07 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.layout.navigation')
|
|
|
|
.directive('navigationHeader', navigationHeader);
|
|
|
|
|
2016-05-20 11:43:47 +02:00
|
|
|
NavigationHeaderController.$inject = ['$window', '$scope', 'currentUser', '$timeout'];
|
2016-04-19 11:58:07 +02:00
|
|
|
|
2016-05-20 11:43:47 +02:00
|
|
|
function NavigationHeaderController($window, $scope, currentUser, $timeout) {
|
2016-04-19 11:58:07 +02:00
|
|
|
var vm = this;
|
2016-05-20 11:43:47 +02:00
|
|
|
vm.url = $window.location.pathname;
|
2016-04-19 11:58:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function navigationHeader() {
|
|
|
|
var directive = {
|
|
|
|
restrict: 'E',
|
2016-06-16 08:10:35 +02:00
|
|
|
templateUrl: '/navigation_header',
|
2016-04-19 11:58:07 +02:00
|
|
|
link: link,
|
2016-05-10 12:43:52 +02:00
|
|
|
scope: true,
|
2016-04-19 11:58:07 +02:00
|
|
|
controller: NavigationHeaderController,
|
|
|
|
controllerAs: 'vm',
|
|
|
|
bindToController: true
|
2016-05-23 12:29:17 +02:00
|
|
|
};
|
2016-04-19 11:58:07 +02:00
|
|
|
|
|
|
|
return directive;
|
|
|
|
|
2016-05-13 12:48:06 +02:00
|
|
|
function link(scope, element, attrs, ctrl) {
|
2016-04-19 11:58:07 +02:00
|
|
|
var visited = ctrl.url;
|
2016-06-20 13:15:45 +02:00
|
|
|
console.log('visited:' + visited);
|
|
|
|
if (visited !== '' && visited !== '/') {
|
2016-05-13 12:48:06 +02:00
|
|
|
element.find('a[href*="' + visited + '"]').addClass('active');
|
|
|
|
}
|
2016-05-21 05:26:19 +02:00
|
|
|
element.find('a').on('click', click);
|
2016-04-19 11:58:07 +02:00
|
|
|
function click(event) {
|
|
|
|
element.find('a').removeClass('active');
|
|
|
|
$(event.target).not('span').addClass('active');
|
2016-05-13 12:48:06 +02:00
|
|
|
}
|
2016-04-19 11:58:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|