webapp.scripts.components.navbar.navbar.directive.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of centraldogma-server Show documentation
Show all versions of centraldogma-server Show documentation
Highly-available version-controlled service configuration repository based on Git, ZooKeeper and HTTP/2 (centraldogma-server)
'use strict';
angular.module('CentralDogmaAdmin')
.directive('activeMenu', function ($translate, $locale, tmhDynamicLocale) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var language = attrs.activeMenu;
scope.$watch(function () {
return $translate.use();
}, function (selectedLanguage) {
if (language === selectedLanguage) {
tmhDynamicLocale.set(language);
element.addClass('active');
} else {
element.removeClass('active');
}
});
}
};
})
.directive('activeLink', function (location) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var clazz = attrs.activeLink;
var path = attrs.href;
path = path.substring(1); //hack because path does bot return including hashbang
scope.location = location;
scope.$watch('location.path()', function (newPath) {
if (path === newPath) {
element.addClass(clazz);
} else {
element.removeClass(clazz);
}
});
}
};
});