mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-04 06:57:50 +01:00
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
(function() {
|
|
|
|
'use strict';
|
|
|
|
angular
|
|
.module('harbor.loading.progress')
|
|
.directive('loadingProgress', loadingProgress);
|
|
|
|
function loadingProgress() {
|
|
var directive = {
|
|
'restrict': 'EA',
|
|
'scope': {
|
|
'toggleInProgress': '=',
|
|
'hideTarget': '='
|
|
},
|
|
'link': link
|
|
};
|
|
|
|
return directive;
|
|
|
|
function link(scope, element, attrs) {
|
|
var spinner = $('<div>')
|
|
.css({'display': 'inline-block'})
|
|
.css({'position': 'relative'})
|
|
.css({'background-image': 'url(/static/resources/img/loading.gif)'})
|
|
.css({'background-position': 'center'})
|
|
.css({'background-size': '107px'})
|
|
.css({'width': '1.2em'})
|
|
.css({'height': '1.2em'})
|
|
.css({'margin': '0 0 1px 8px'})
|
|
.css({'vertical-align': 'middle'});
|
|
|
|
scope.$watch('toggleInProgress', function(current) {
|
|
if(scope.toggleInProgress) {
|
|
element.append(spinner);
|
|
element.attr('disabled', 'disabled');
|
|
if(scope.hideTarget) {
|
|
element.append(spinner);
|
|
element.hide();
|
|
}
|
|
}else{
|
|
scope.hideTarget = false;
|
|
element.show();
|
|
element.find('div').remove();
|
|
element.removeAttr('disabled');
|
|
}
|
|
});
|
|
|
|
}
|
|
}
|
|
|
|
})(); |