2016-04-19 11:58:07 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.layout.navigation')
|
|
|
|
.directive('navigationDetails', navigationDetails);
|
|
|
|
|
2016-06-01 08:50:34 +02:00
|
|
|
NavigationDetailsController.$inject = ['$window', '$location', '$scope', 'getParameterByName'];
|
2016-04-19 11:58:07 +02:00
|
|
|
|
2016-06-01 08:50:34 +02:00
|
|
|
function NavigationDetailsController($window, $location, $scope, getParameterByName) {
|
2016-04-19 11:58:07 +02:00
|
|
|
var vm = this;
|
2016-06-01 08:01:35 +02:00
|
|
|
|
|
|
|
vm.projectId = getParameterByName('project_id', $location.absUrl());
|
|
|
|
|
|
|
|
$scope.$on('$locationChangeSuccess', function() {
|
|
|
|
vm.projectId = getParameterByName('project_id', $location.absUrl());
|
2016-05-01 19:46:50 +02:00
|
|
|
});
|
2016-06-01 08:50:34 +02:00
|
|
|
|
2016-05-31 12:49:16 +02:00
|
|
|
vm.path = $location.path();
|
2016-04-19 11:58:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function navigationDetails() {
|
|
|
|
var directive = {
|
|
|
|
restrict: 'E',
|
2016-06-16 08:10:35 +02:00
|
|
|
templateUrl: '/navigation_detail',
|
2016-04-19 11:58:07 +02:00
|
|
|
link: link,
|
|
|
|
scope: {
|
2016-05-31 12:49:16 +02:00
|
|
|
'target': '='
|
2016-04-19 11:58:07 +02:00
|
|
|
},
|
|
|
|
replace: true,
|
|
|
|
controller: NavigationDetailsController,
|
|
|
|
controllerAs: 'vm',
|
|
|
|
bindToController: true
|
2016-05-23 12:29:17 +02:00
|
|
|
};
|
2016-04-19 11:58:07 +02:00
|
|
|
|
|
|
|
return directive;
|
|
|
|
|
|
|
|
function link(scope, element, attrs, ctrl) {
|
2016-06-01 08:50:34 +02:00
|
|
|
|
2016-05-31 12:49:16 +02:00
|
|
|
var visited = ctrl.path.substring(1);
|
2016-05-04 12:42:05 +02:00
|
|
|
if(visited.indexOf('?') >= 0) {
|
2016-05-25 06:13:07 +02:00
|
|
|
visited = ctrl.url.substring(1, ctrl.url.indexOf('?'));
|
2016-05-04 12:42:05 +02:00
|
|
|
}
|
2016-04-19 11:58:07 +02:00
|
|
|
|
2016-05-31 12:49:16 +02:00
|
|
|
if(visited) {
|
|
|
|
element.find('a[tag="' + visited + '"]').addClass('active');
|
|
|
|
}else{
|
|
|
|
element.find('a:first').addClass('active');
|
|
|
|
}
|
|
|
|
|
2016-06-13 12:12:46 +02:00
|
|
|
ctrl.target = visited;
|
2016-05-25 06:13:07 +02:00
|
|
|
element.find('a').on('click', click);
|
|
|
|
|
2016-04-19 11:58:07 +02:00
|
|
|
function click(event) {
|
|
|
|
element.find('a').removeClass('active');
|
2016-05-18 11:03:06 +02:00
|
|
|
$(event.target).addClass('active');
|
2016-05-31 12:49:16 +02:00
|
|
|
ctrl.target = $(this).attr('tag');
|
|
|
|
scope.$apply();
|
2016-04-19 11:58:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|