/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
(function() {
'use strict';
/**
* sgGravatarImage - A simple Gravatar directive (based on http://blog.lingohub.com/2014/08/better-ux-with-angularjs-directives/)
* @memberof SOGo.Common
* @example:
*/
sgGravatarImage.$inject = ['Gravatar'];
function sgGravatarImage(Gravatar) {
return {
restrict: 'AE',
replace: true,
required: 'email',
template: '',
link: function(scope, element, attrs) {
var size = attrs.size;
element.attr('width', size);
element.attr('height', size);
attrs.$observe('email', function(value) {
if (!value) { return; }
scope.url = Gravatar(value, size);
});
}
};
}
angular
.module('SOGo.Common')
.directive('sgGravatarImage', sgGravatarImage);
})();