2016-07-07 18:03:32 +02:00
|
|
|
/*
|
|
|
|
Copyright (c) 2016 VMware, Inc. All Rights Reserved.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
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-09-02 12:16:58 +02:00
|
|
|
|
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-09-02 12:16:58 +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-07-05 07:03:18 +02:00
|
|
|
templateUrl: '/navigation_detail?timestamp=' + new Date().getTime(),
|
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-09-02 12:16:58 +02:00
|
|
|
|
2016-05-31 12:49:16 +02:00
|
|
|
var visited = ctrl.path.substring(1);
|
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-09-02 12:16:58 +02:00
|
|
|
|
|
|
|
scope.$watch('vm.target', function(current) {
|
|
|
|
if(current) {
|
|
|
|
ctrl.target = current;
|
|
|
|
element.find('a').removeClass('active');
|
|
|
|
element.find('a[tag="' + ctrl.target + '"]').addClass('active');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|