Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs_theme/css/copy-button.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.copy-block-button {
position: absolute;
top: 6px;
right: 6px;
font-size: 12px;
padding: 2px 6px;
cursor: pointer;

background: #f7f7f9;
border: 1px solid #e1e1e8;
border-radius: 3px;

color: #dc322f !important;

box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}

.copy-block-button span {
color: #dc322f !important;
}
19 changes: 19 additions & 0 deletions docs_theme/js/copy-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
document.addEventListener("DOMContentLoaded", function () {
document.querySelectorAll("pre > code").forEach(function (codeBlock) {
const button = document.createElement("button");
button.className = "copy-block-button";
button.type = "button";
button.textContent = "Copy";

button.addEventListener("click", function () {
navigator.clipboard.writeText(codeBlock.textContent).then(function () {
button.textContent = "Copied!";
setTimeout(() => button.textContent = "Copy", 1200);
});
});

const pre = codeBlock.parentNode;
pre.style.position = "relative";
pre.appendChild(button);
});
});
3 changes: 3 additions & 0 deletions docs_theme/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<link href="{{ 'css/bootstrap.css'|url }}" rel="stylesheet">
<link href="{{ 'css/bootstrap-responsive.css'|url }}" rel="stylesheet">
<link href="{{ 'css/default.css'|url }}" rel="stylesheet">
{% for path in config.extra_css %}
<link href="{{ path|url }}" rel="stylesheet">
{% endfor %}


<script type="text/javascript">
Expand Down
6 changes: 6 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,9 @@ nav:
- 'Mozilla Grant': 'community/mozilla-grant.md'
- 'Funding': 'community/funding.md'
- 'Jobs': 'community/jobs.md'

extra_css:
- css/copy-button.css

extra_javascript:
- js/copy-button.js