feat(about): add directive makerInfo to show maker group info

This commit is contained in:
OldHawk
2017-10-22 01:18:51 +08:00
parent f079bd718c
commit e3a1e6f77d

View File

@@ -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('<a href="#" ui-sref="about.group({makerId: \'' + maker._id + '\'})" ng-click="$event.stopPropagation();">-=' + maker.name + '=-</a>');
if (e) {
e.addClass(cls ? cls : '');
e.attr('title', title);
element.html(e);
$compile(element.contents())(scope);
}
}
});
}
}
}());