mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-28 21:25:55 +01:00
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
(function() {
|
|
|
|
'use strict';
|
|
|
|
angular
|
|
.module('harbor.repository')
|
|
.directive('pullCommand', pullCommand);
|
|
|
|
function PullCommandController() {
|
|
|
|
}
|
|
|
|
function pullCommand() {
|
|
var directive = {
|
|
'restrict': 'E',
|
|
'templateUrl': '/static/ng/resources/js/components/repository/pull-command.directive.html',
|
|
'scope': {
|
|
'repoName': '@',
|
|
'tag': '@'
|
|
},
|
|
'link': link,
|
|
'controller': PullCommandController,
|
|
'controllerAs': 'vm',
|
|
'bindToController': true
|
|
};
|
|
return directive;
|
|
|
|
function link(scope, element, attrs, ctrl) {
|
|
|
|
ctrl.harborRegUrl = $('#HarborRegUrl').val() + '/';
|
|
|
|
ZeroClipboard.config( { swfPath: "/static/ng/vendors/zc/v2.2.0/ZeroClipboard.swf" } );
|
|
var clip = new ZeroClipboard(element.find('a'));
|
|
element.find('span').tooltip({'trigger': 'click'});
|
|
|
|
clip.on("ready", function() {
|
|
console.log("Flash movie loaded and ready.");
|
|
this.on("aftercopy", function(event) {
|
|
console.log("Copied text to clipboard: " + event.data["text/plain"]);
|
|
element.find('span').tooltip('show');
|
|
setTimeout(function(){
|
|
element.find('span').tooltip('hide');
|
|
}, 1000);
|
|
});
|
|
});
|
|
|
|
clip.on("error", function(event) {
|
|
console.log('error[name="' + event.name + '"]: ' + event.message);
|
|
ZeroClipboard.destroy();
|
|
element.find('span').tooltip('destroy');
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})(); |