2016-04-13 12:55:05 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.app')
|
|
|
|
.directive('navigationTab', navigationTab);
|
2016-04-17 17:53:26 +02:00
|
|
|
|
|
|
|
NavigationTabController.$inject = ['$window'];
|
2016-04-13 12:55:05 +02:00
|
|
|
|
2016-04-17 17:53:26 +02:00
|
|
|
function NavigationTabController($window) {
|
|
|
|
var vm = this;
|
|
|
|
vm.location = $window.location.pathname;
|
|
|
|
vm.closePane = closePane;
|
|
|
|
function closePane() {
|
|
|
|
vm.visible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-13 12:55:05 +02:00
|
|
|
function navigationTab() {
|
|
|
|
var directive = {
|
2016-04-14 19:50:10 +02:00
|
|
|
restrict: 'E',
|
|
|
|
templateUrl: getTemplateUrl,
|
|
|
|
link: link,
|
2016-04-17 17:53:26 +02:00
|
|
|
scope: {
|
|
|
|
templateUrl: "@",
|
|
|
|
visible: "="
|
|
|
|
},
|
|
|
|
replace: true,
|
|
|
|
controller: NavigationTabController,
|
|
|
|
controllerAs: 'vm',
|
|
|
|
bindToController: true
|
2016-04-13 12:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return directive;
|
|
|
|
|
2016-04-14 19:50:10 +02:00
|
|
|
function getTemplateUrl(element, attrs) {
|
2016-04-17 17:53:26 +02:00
|
|
|
return '/static/ng/resources/js/layout/'+ attrs.templateUrl;
|
2016-04-14 19:50:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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');
|
2016-04-17 17:53:26 +02:00
|
|
|
$(event.target).not('span').addClass('active');
|
2016-04-13 12:55:05 +02:00
|
|
|
}
|
2016-04-14 19:50:10 +02:00
|
|
|
|
|
|
|
}
|
2016-04-17 17:53:26 +02:00
|
|
|
|
2016-04-13 12:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
})();
|