2016-04-13 12:55:05 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.app')
|
|
|
|
.directive('navigationTab', navigationTab);
|
|
|
|
|
|
|
|
function navigationTab() {
|
|
|
|
var directive = {
|
2016-04-14 19:50:10 +02:00
|
|
|
restrict: 'E',
|
|
|
|
templateUrl: getTemplateUrl,
|
|
|
|
link: link,
|
|
|
|
controller: controller
|
2016-04-13 12:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return directive;
|
|
|
|
|
2016-04-14 19:50:10 +02:00
|
|
|
function getTemplateUrl(element, attrs) {
|
|
|
|
return '/static/ng/resources/js/components/'+ attrs.templateUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
function link(scope, element, attrs, ctrl) {
|
|
|
|
|
|
|
|
if (attrs.templateUrl.indexOf("navigation-tab") >= 0) {
|
|
|
|
element.find('a[href$="' + ctrl.location + '"]').addClass('active');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attrs.templateUrl.indexOf("navigation-details") >= 0) {
|
|
|
|
element.find('a:first').addClass('active');
|
2016-04-13 12:55:05 +02:00
|
|
|
}
|
|
|
|
|
2016-04-14 19:50:10 +02:00
|
|
|
element.on('click', click);
|
|
|
|
|
|
|
|
function click(event) {
|
|
|
|
element.find('a').removeClass('active');
|
|
|
|
$(event.target).addClass('active');
|
2016-04-13 12:55:05 +02:00
|
|
|
}
|
2016-04-14 19:50:10 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
controller.$inject = ['$window'];
|
|
|
|
|
|
|
|
function controller($window) {
|
|
|
|
var vm = this;
|
|
|
|
vm.location = $window.location.pathname;
|
2016-04-13 12:55:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|