34 lines
No EOL
922 B
JavaScript
34 lines
No EOL
922 B
JavaScript
/**
|
|
* An element which displays an avatar for the given {email,name} or hash.
|
|
*/
|
|
angular.module('quay').directive('avatar', function () {
|
|
var directiveDefinitionObject = {
|
|
priority: 0,
|
|
templateUrl: '/static/directives/avatar.html',
|
|
replace: false,
|
|
transclude: true,
|
|
restrict: 'C',
|
|
scope: {
|
|
'hash': '=hash',
|
|
'email': '=email',
|
|
'name': '=name',
|
|
'size': '=size'
|
|
},
|
|
controller: function($scope, $element, AvatarService) {
|
|
$scope.AvatarService = AvatarService;
|
|
|
|
var refreshHash = function() {
|
|
if (!$scope.name && !$scope.email) { return; }
|
|
$scope._hash = AvatarService.computeHash($scope.email, $scope.name);
|
|
};
|
|
|
|
$scope.$watch('hash', function(hash) {
|
|
$scope._hash = hash;
|
|
});
|
|
|
|
$scope.$watch('name', refreshHash);
|
|
$scope.$watch('email', refreshHash);
|
|
}
|
|
};
|
|
return directiveDefinitionObject;
|
|
}); |