Add copy to clipboard clone URL

This commit is contained in:
Tomofumi Tanaka
2013-07-16 01:10:52 +09:00
parent 71a3d79c82
commit fc7481c60c
6 changed files with 43 additions and 3 deletions

View File

@@ -8,5 +8,34 @@ $(function(){
$('img[data-toggle=tooltip]').tooltip();
$('a[data-toggle=tooltip]').tooltip();
// copy to clipboard
(function() {
// Find ZeroClipboard.swf file URI from ZeroClipboard JavaScript file path.
// NOTE(tanacasino) I think this way is wrong... but i don't know correct way.
var moviePath = (function() {
var zclipjs = "ZeroClipboard.min.js";
var scripts = document.getElementsByTagName("script");
var i = scripts.length;
while(i--) {
var match = scripts[i].src.match(zclipjs + "$");
if(match) {
return match.input.substr(0, match.input.length - 6) + 'swf';
}
}
})();
var clip = new ZeroClipboard($("#repository-url-copy"), {
moviePath: moviePath
});
var title = $('#repository-url-copy').attr('title');
clip.on('complete', function(client, args) {
$(clip.htmlBridge).attr('title', 'copied!').tooltip('fixTitle').tooltip('show');
$(clip.htmlBridge).attr('title', title).tooltip('fixTitle');
});
$(clip.htmlBridge).tooltip({
title: title,
placement: $('#repository-url-copy').attr('data-placement')
});
})();
prettyPrint();
});