9350de6f15
Fixes issue with clipboard.js throwing an error
45 lines
1 KiB
JavaScript
45 lines
1 KiB
JavaScript
|
|
/*= require clipboard */
|
|
|
|
(function() {
|
|
var genericError, genericSuccess, showTooltip;
|
|
|
|
genericSuccess = function(e) {
|
|
showTooltip(e.trigger, 'Copied!');
|
|
e.clearSelection();
|
|
return $(e.trigger).blur();
|
|
};
|
|
|
|
genericError = function(e) {
|
|
var key;
|
|
if (/Mac/i.test(navigator.userAgent)) {
|
|
key = '⌘';
|
|
} else {
|
|
key = 'Ctrl';
|
|
}
|
|
return showTooltip(e.trigger, "Press " + key + "-C to copy");
|
|
};
|
|
|
|
showTooltip = function(target, title) {
|
|
return $(target).tooltip({
|
|
container: 'body',
|
|
html: 'true',
|
|
placement: 'auto bottom',
|
|
title: title,
|
|
trigger: 'manual'
|
|
}).tooltip('show').one('mouseleave', function() {
|
|
return $(this).tooltip('hide');
|
|
});
|
|
};
|
|
|
|
$(function() {
|
|
var clipboard;
|
|
|
|
if ($('body').attr('data-page') !== 'projects:boards:show') {
|
|
clipboard = new Clipboard('[data-clipboard-target], [data-clipboard-text]');
|
|
clipboard.on('success', genericSuccess);
|
|
return clipboard.on('error', genericError);
|
|
}
|
|
});
|
|
|
|
}).call(this);
|