mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-07 05:02:04 +02:00
feat(invitations): add directive of vipFlag to show user`s VIP flag
This commit is contained in:
37
modules/users/client/directives/vip-flag.client.directive.js
Normal file
37
modules/users/client/directives/vip-flag.client.directive.js
Normal file
@@ -0,0 +1,37 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular.module('users')
|
||||
.directive('vipFlag', vipFlag);
|
||||
|
||||
vipFlag.$inject = ['$compile', '$translate'];
|
||||
|
||||
function vipFlag($compile, $translate) {
|
||||
var directive = {
|
||||
restrict: 'A',
|
||||
link: link
|
||||
};
|
||||
|
||||
return directive;
|
||||
|
||||
function link(scope, element, attrs) {
|
||||
scope.$watch(attrs.vipFlag, function (s) {
|
||||
if (s) {
|
||||
var user = s;
|
||||
var title = $translate.instant('USER_IS_VIP', {name: user.displayName});
|
||||
var cls = attrs.vipClass;
|
||||
|
||||
var e = angular.element('<span class="vip-flag" ng-click="$event.stopPropagation();" ng-if="user.isVip"><kbd>VIP</kbd></span>');
|
||||
|
||||
if (e) {
|
||||
e.addClass(cls ? cls : '');
|
||||
e.attr('title', title);
|
||||
|
||||
element.html(e);
|
||||
$compile(element.contents())(scope);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}());
|
||||
Reference in New Issue
Block a user