This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/directives/ui/feedback-bar.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-11-12 16:09:47 +00:00
/**
* An element which displays a feedback bar when an action has been taken.
*/
angular.module('quay').directive('feedbackBar', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/feedback-bar.html',
replace: false,
transclude: true,
restrict: 'C',
scope: {
'feedback': '=feedback'
},
controller: function($scope, $element, AvatarService, Config, UIService, $timeout, StringBuilderService) {
$scope.viewCounter = 0;
$scope.formattedMessage = '';
$scope.$watch('feedback', function(feedback) {
if (feedback) {
$scope.formattedMessage = StringBuilderService.buildTrustedString(feedback.message, feedback.data || {}, 'span');
$scope.viewCounter++;
} else {
$scope.viewCounter = 0;
}
});
$($element).find('.feedback-bar-element')
.on('webkitAnimationEnd oanimationend oAnimationEnd msAnimationEnd animationend',
function(e) {
$scope.$apply(function() {
$scope.viewCounter = 0;
});
});
}
};
return directiveDefinitionObject;
});