mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-12-03 16:24:01 +03:00
Merge d690b86f9a into 442444f0be
This commit is contained in:
commit
2b7e605b78
20
docs_theme/css/copy-button.css
Normal file
20
docs_theme/css/copy-button.css
Normal file
|
|
@ -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
docs_theme/js/copy-button.js
Normal file
19
docs_theme/js/copy-button.js
Normal file
|
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
<link href="{{ 'css/bootstrap.css'|url }}" rel="stylesheet">
|
<link href="{{ 'css/bootstrap.css'|url }}" rel="stylesheet">
|
||||||
<link href="{{ 'css/bootstrap-responsive.css'|url }}" rel="stylesheet">
|
<link href="{{ 'css/bootstrap-responsive.css'|url }}" rel="stylesheet">
|
||||||
<link href="{{ 'css/default.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">
|
<script type="text/javascript">
|
||||||
|
|
|
||||||
|
|
@ -86,3 +86,9 @@ nav:
|
||||||
- 'Kickstarter Announcement': 'community/kickstarter-announcement.md'
|
- 'Kickstarter Announcement': 'community/kickstarter-announcement.md'
|
||||||
- 'Mozilla Grant': 'community/mozilla-grant.md'
|
- 'Mozilla Grant': 'community/mozilla-grant.md'
|
||||||
- 'Jobs': 'community/jobs.md'
|
- 'Jobs': 'community/jobs.md'
|
||||||
|
|
||||||
|
extra_css:
|
||||||
|
- css/copy-button.css
|
||||||
|
|
||||||
|
extra_javascript:
|
||||||
|
- js/copy-button.js
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user