Skip to content

Commit ec754cf

Browse files
Fix copy-path button
1 parent ad18fe0 commit ec754cf

2 files changed

Lines changed: 12 additions & 25 deletions

File tree

‎src/librustdoc/html/static/css/rustdoc.css‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,24 +1627,27 @@ a.tooltip:hover::after {
16271627
color:var(--copy-path-button-color);
16281628
background:var(--main-background-color);
16291629
height:34px;
1630+
width:33px;
16301631
margin-left:10px;
16311632
padding:0;
16321633
padding-left:2px;
16331634
border:0;
1634-
width:33px;
1635-
line-height:0;
16361635
font-size:0;
16371636
}
1638-
1639-
#copy-path:before {
1637+
#copy-path::before {
16401638
filter:var(--copy-path-img-filter);
16411639
content:url('clipboard-24048e6d87f63d07.svg');
1642-
width:19px;
1643-
height:18px;
16441640
}
1645-
#copy-path:hover:before {
1641+
#copy-path:hover::before {
16461642
filter:var(--copy-path-img-hover-filter);
16471643
}
1644+
#copy-path.clicked::before {
1645+
/* Checkmark <https://www.svgrepo.com/svg/335033/checkmark> */
1646+
content:url('data:image/svg+xml,<svg viewBox="-1 -1 23 23" xmlns="http://www.w3.org/2000/svg" \
1647+
fill="black" height="18px">\
1648+
<g><path d="M9 19.414l-6.707-6.707 1.414-1.414L9 16.586 20.293 5.293l1.414 1.414"></path>\
1649+
</g></svg>');
1650+
}
16481651

16491652
@keyframes rotating {
16501653
from {

‎src/librustdoc/html/static/js/main.js‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,31 +1797,15 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
17971797
document.execCommand("copy");
17981798
document.body.removeChild(el);
17991799

1800-
// There is always one children, but multiple childNodes.
1801-
but.children[0].style.display="none";
1802-
1803-
lettmp;
1804-
if(but.childNodes.length<2){
1805-
tmp=document.createTextNode("✓");
1806-
but.appendChild(tmp);
1807-
}else{
1808-
onEachLazy(but.childNodes,e=>{
1809-
if(e.nodeType===Node.TEXT_NODE){
1810-
tmp=e;
1811-
returntrue;
1812-
}
1813-
});
1814-
tmp.textContent="✓";
1815-
}
1800+
but.classList.add("clicked");
18161801

18171802
if(reset_button_timeout!==null){
18181803
window.clearTimeout(reset_button_timeout);
18191804
}
18201805

18211806
functionreset_button(){
1822-
tmp.textContent="";
18231807
reset_button_timeout=null;
1824-
but.children[0].style.display="";
1808+
but.classList.remove("clicked");
18251809
}
18261810

18271811
reset_button_timeout=window.setTimeout(reset_button,1000);

0 commit comments

Comments
 (0)