Skip to content

Commit 52affc6

Browse files
committed
disable copy button if feature unavailable [fix #1]
1 parent 3bb163c commit 52affc6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

templates/reveal.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
background-position: left 0%;
5050
}
5151

52+
.button:disabled {
53+
box-shadow: none;
54+
filter: grayscale();
55+
pointer-events: none;
56+
}
57+
5258
.footer {
5359
position: fixed;
5460
bottom: 0;

templates/view.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
background-position: left 0%;
5050
}
5151

52+
.button:disabled {
53+
box-shadow: none;
54+
filter: grayscale();
55+
pointer-events: none;
56+
}
57+
5258
.footer {
5359
position: fixed;
5460
bottom: 0;
@@ -124,12 +130,14 @@
124130
<div id="secret" class="monospace">
125131
{{- .Secret -}}
126132
</div>
127-
<button style="margin-top: 3rem; user-select: none;" class="center button" type="button" onclick="copySecretToClipboard()">
133+
<button id="btnCopy" style="margin-top: 3rem; user-select: none;" class="center button" type="button" onclick="copySecretToClipboard()" disabled=true>
128134
{{- translate "msg_copy" -}}
129135
</button>
130136
</div>
131137
<div style="font-size: 16px;" class="center footer">
132138
{{ translate "msg_views_remaining" .Views }}
133139
</div>
140+
<!-- styles onload script gets executed even when this body is swapped in via reveal -->
141+
<style onload="if (navigator.clipboard) { document.getElementById('btnCopy').disabled = false; }"></style>
134142
</body>
135143
</html>

0 commit comments

Comments
 (0)