Separate ZeroClipboard button as the helper.

This commit is contained in:
takezoe
2013-08-24 13:22:17 +09:00
parent cd298eb5c1
commit 95a658defa
5 changed files with 76 additions and 53 deletions

View File

@@ -2,43 +2,15 @@ $(function(){
// disable Ajax cache
$.ajaxSetup({ cache: false });
// repository url text field
$('#repository-url').click(function(){
this.select(0, this.value.length);
});
// activate tooltip
$('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');
$('#repository-url-copy').removeAttr('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')
});
})();
// syntax highlighting by google-code-prettify
prettyPrint();
});