Skip to content

Commit 4223f87

Browse files
committed
addressing review comments from Robert Young <[email protected]>
Signed-off-by: Keith Wall <[email protected]>
1 parent 9dde7bf commit 4223f87

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

_includes/asciidoctor-scripts/clipboard.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
document.querySelectorAll("code").forEach((codeElem) => {
77
if (codeElem.textContent && codeElem.closest('.listingblock')) {
88
let selectableCode = codeElem.textContent;
9-
if (codeElem.getAttribute("data-lang") === "terminal") {
9+
if (codeElem.dataset.lang === "terminal") {
1010
let codeLines = codeElem.textContent.split(/\n/);
1111
for (let idx = 0; idx < codeLines.length; idx++) {
12-
// line is a shell command, remove the console prompt
13-
codeLines[idx] = codeLines[idx].replace("$ ", "")
12+
// line is a shell command, remove any console prompt
13+
codeLines[idx] = codeLines[idx].replace(/^\$ +/, "")
1414
}
1515
selectableCode = codeLines.join("\n");
1616
}
1717
let clipboardBtn = document.createElement("button");
18-
clipboardBtn.setAttribute('data-clipboard-text', selectableCode);
18+
clipboardBtn.dataset.clipboardText = selectableCode;
1919
clipboardBtn.className = "clipboardBtn";
2020
codeElem.parentNode.insertBefore(clipboardBtn, codeElem.nextSibling);
2121
atLeastOne = true;

_sass/kroxylicious.scss

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,25 @@ b.conum * {
335335
border-top: 1px solid $kroxy-light;
336336
}
337337

338+
.kroxylicious-guide pre.CodeRay {
339+
/* enable clipboardButton to be absolutely positioned within the pre */
340+
position: relative;
341+
}
342+
343+
.kroxylicious-guide pre.CodeRay:hover .clipboardBtn {
344+
opacity: 1.0;
345+
}
346+
338347
.kroxylicious-guide .clipboardBtn {
339348
background:url(/assets/theme/images/clippy.svg) no-repeat;
340-
float: right;
341-
vertical-align: top;
349+
display: inline-block;
350+
position: absolute;
351+
top: 6px;
352+
right: 6px;
342353
cursor:pointer;
343354
width: 13px;
344355
height: 15px;
345356
background-size:contain;
346357
border: none;
347-
}
358+
opacity: 0;
359+
}

0 commit comments

Comments
 (0)