diff --git a/dev/docs/assets/snippets.css b/dev/docs/assets/snippets.css index 4fb200addb..e5ee48f170 100644 --- a/dev/docs/assets/snippets.css +++ b/dev/docs/assets/snippets.css @@ -83,6 +83,26 @@ font-family: courier, lucidia; } +.anchor-container { + position: relative; +} + +.anchor-button-overlay { + position: absolute; + top: 0px; + right: 5px; + height: 28px; + width: 28px; + transition: .3s ease; + background-color: #2372a3; +} + +.anchor-button { + border-style: none; + background: none; + cursor: pointer; +} + /* Styles for the copy-to-clipboard button */ .copyable-container { position: relative; diff --git a/dev/docs/assets/snippets.js b/dev/docs/assets/snippets.js index 9d4da921da..86e9a2c117 100644 --- a/dev/docs/assets/snippets.js +++ b/dev/docs/assets/snippets.js @@ -57,6 +57,30 @@ function supportsCopying() { !!document.queryCommandSupported('copy'); } +// Copies the given string to the clipboard. +function copyStringToClipboard(string) { + var textArea = document.createElement("textarea"); + textArea.value = string; + document.body.appendChild(textArea); + textArea.focus(); + textArea.select(); + + if (!supportsCopying()) { + alert('Unable to copy to clipboard (not supported by browser)'); + return; + } + + try { + document.execCommand('copy'); + } finally { + document.body.removeChild(textArea); + } +} + +function fixHref(anchor, id) { + anchor.href = window.location.href.replace(/#.*$/, '') + '#' + id; +} + // Copies the text inside the currently visible snippet to the clipboard, or the // given element, if any. function copyTextToClipboard(element) { diff --git a/dev/snippets/config/skeletons/application.html b/dev/snippets/config/skeletons/application.html index 7d7e17bab4..56b648cc03 100644 --- a/dev/snippets/config/skeletons/application.html +++ b/dev/snippets/config/skeletons/application.html @@ -1,4 +1,13 @@ {@inject-html} + +