randomize default avatar

This commit is contained in:
Girish Ramakrishnan
2015-07-29 15:57:15 -07:00
parent 157f972b20
commit e7bf8452ab

View File

@@ -185,11 +185,12 @@ app.controller('StepController', ['$scope', '$location', 'Wizard', function ($sc
// ensure image got loaded before setting the preview avatar
var image = document.createElement('img');
var randomIndex = Math.floor(Math.random() * $scope.wizard.availableAvatars.length);
image.onload = function() {
$scope.$apply(function () { $scope.wizard.setPreviewAvatar($scope.wizard.availableAvatars[0]); });
$scope.$apply(function () { $scope.wizard.setPreviewAvatar($scope.wizard.availableAvatars[randomIndex]); });
image = null;
};
image.src = $scope.wizard.availableAvatars[0].data || $scope.wizard.availableAvatars[0].url;
image.src = $scope.wizard.availableAvatars[randomIndex].data || $scope.wizard.availableAvatars[randomIndex].url;
}]);
app.controller('FinishController', ['$scope', '$location', '$timeout', 'Wizard', 'Client', function ($scope, $location, $timeout, Wizard, Client) {