diff --git a/modules/users/client/directives/maker-info.client.directive.js b/modules/users/client/directives/maker-info.client.directive.js new file mode 100644 index 00000000..389d399a --- /dev/null +++ b/modules/users/client/directives/maker-info.client.directive.js @@ -0,0 +1,36 @@ +(function () { + 'use strict'; + + angular.module('users') + .directive('makerInfo', makerInfo); + + makerInfo.$inject = ['$compile', '$translate']; + + function makerInfo($compile, $translate) { + var directive = { + restrict: 'A', + link: link + }; + + return directive; + + function link(scope, element, attrs) { + scope.$watch(attrs.makerInfo, function (s) { + if (s) { + var maker = s; + var title = $translate.instant('MAKER_INFO_TITLE', {name: maker.name}); + var cls = attrs.infoClass; + var e = angular.element('-=' + maker.name + '=-'); + + if (e) { + e.addClass(cls ? cls : ''); + e.attr('title', title); + + element.html(e); + $compile(element.contents())(scope); + } + } + }); + } + } +}());