harbor/static/ng/resources/js/components/repository/pull-command.directive.js

55 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-05-05 12:35:52 +02:00
(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) {
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();
2016-05-06 14:37:44 +02:00
element.find('span').tooltip('destroy');
2016-05-05 12:35:52 +02:00
});
}
}
})();