Move to Angular 1.5
This has been reasonably well tested, but further testing should be done on staging. Also optimizes avatar handling to use a constant size and not 404. Fixes #1434
This commit is contained in:
parent
dc42f22b79
commit
4aab834156
19 changed files with 91 additions and 133 deletions
|
@ -16,20 +16,38 @@ angular.module('quay').directive('avatar', function () {
|
|||
$scope.AvatarService = AvatarService;
|
||||
$scope.Config = Config;
|
||||
$scope.isLoading = true;
|
||||
$scope.hasGravatar = false;
|
||||
$scope.showGravatar = false;
|
||||
$scope.loadGravatar = false;
|
||||
|
||||
$scope.imageCallback = function(r) {
|
||||
$timeout(function() {
|
||||
$scope.isLoading = false;
|
||||
$scope.hasGravatar = r;
|
||||
}, 1);
|
||||
$scope.imageCallback = function(result) {
|
||||
$scope.isLoading = false;
|
||||
|
||||
if (!result) {
|
||||
$scope.showGravatar = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine whether the gravatar is blank.
|
||||
var canvas = document.createElement("canvas");
|
||||
canvas.width = 512;
|
||||
canvas.height = 512;
|
||||
|
||||
var ctx = canvas.getContext("2d");
|
||||
ctx.drawImage($element.find('img')[0], 0, 0);
|
||||
|
||||
var blank = document.createElement("canvas");
|
||||
blank.width = 512;
|
||||
blank.height = 512;
|
||||
|
||||
var isBlank = canvas.toDataURL('text/png') == blank.toDataURL('text/png');
|
||||
$scope.showGravatar = !isBlank;
|
||||
};
|
||||
|
||||
$scope.$watch('size', function(size) {
|
||||
size = size * 1 || 16;
|
||||
$scope.fontSize = (size - 4) + 'px';
|
||||
$scope.lineHeight = size + 'px';
|
||||
$scope.imageSize = size;
|
||||
});
|
||||
|
||||
$scope.$watch('data', function(data) {
|
||||
|
|
Reference in a new issue