Initial commit
This commit is contained in:
18
app/assets/javascripts/clipboard.js
Normal file
18
app/assets/javascripts/clipboard.js
Normal file
@@ -0,0 +1,18 @@
|
||||
$(document).on("click", "[data-behavior=clipboard]", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Copy the value of the link's `href` attribute
|
||||
var value = $(this).attr("href");
|
||||
|
||||
// Creates a temporary input field to copy from
|
||||
var copyToClipboard = function(value) {
|
||||
var $temp = $("<input>");
|
||||
$("body").append($temp);
|
||||
$temp.val(value).select();
|
||||
document.execCommand("copy");
|
||||
$temp.remove();
|
||||
}
|
||||
|
||||
// Perform the copying
|
||||
copyToClipboard(value);
|
||||
});
|
||||
Reference in New Issue
Block a user