Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add a copy URI icon #211

Merged
merged 12 commits into from
Jun 7, 2021
11 changes: 11 additions & 0 deletions css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,15 @@ svg{
.user-select-none{
user-select:none;
}

.cpy-clipboard {
bryan-brancotte marked this conversation as resolved.
Show resolved Hide resolved
padding-left: 1rem;
padding-top: 1rem;
color : #01308d ;
}

.cpy-clipboard:hover {
color : #020c22 ;
cursor: pointer;
}
/*end of file*/
18 changes: 18 additions & 0 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,22 @@ window.onload = function() {
}
$("input[name='show-detail']").prop("checked" , (localStorage.getItem("show-detail")||"true") == "true");
$("input[name='show-community-usage']").prop("checked" , (localStorage.getItem("show-community-usage")||"false") == "true");

//copies the uri to the clipboard
//placed here because it needs the DOM to be fully loaded first
$(document).on('click','#cpy-uri',function(e){
var text = document.querySelector('.uri-val > .label');
//copying to the clipboard
navigator.clipboard.writeText(text.innerText);

//showing the copied tooltip
$("#cpy-uri").attr('title', "Copied!")
.tooltip('show');

//changing the icon to a check shape indicating success
$(this).addClass("fa-check").removeClass("fa-copy");


}
);
};
8 changes: 7 additions & 1 deletion js/tree-edam-stand-alone.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,13 @@ function interactive_edam_browser(){
if (tootip !== undefined) {
html_tootip=" data-toggle=\"tooltip\" data-placement='top' title=\""+tootip+"\"";
}
$("<tr><th><span"+html_tootip+">"+name+"</span></th><td class=\""+id+"\">"+interactive_edam_uri(value, translate_uri_to_text)+"</td></tr>").appendTo(table);

//adding the copy icon, can be extendable to other rows
let cpyInfo ="";
if (id=="uri-val"){
cpyInfo ="" + "<i class=\"fas fa-copy cpy-clipboard\""+ "id=\"cpy-uri\""+">" + " </i>" ;
}
$("<tr><th><span"+html_tootip+">"+name+"</span></th><td class=\""+id+"\">"+interactive_edam_uri(value, translate_uri_to_text)+cpyInfo+"</td></tr>").appendTo(table);
return id;
}

Expand Down