commit 5db0678d00e61f266bcca667706e7afa70b031a9
parent ed28b97215ab086956c9479dd44f9e2f3b5ef503
Author: Fredrik <moi@knutsen.co>
Date: Tue, 13 Nov 2018 23:14:21 +0000
Merge pull request #15 from Demonstrandum/devel
Clipboard working for iOS
Diffstat:
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/public/styles.css b/public/styles.css
@@ -135,18 +135,24 @@ input[type=text]:focus {
input[type=checkbox] { display:none; }
input[type=checkbox] + label:before {
- font-family: "Font Awesome 5 Free", FontAwesome;
- font-style: normal;
- font-weight: normal;
- text-decoration: inherit;
display: inline-block;
+ font-style: normal;
+ font-variant: normal;
+ text-rendering: auto;
+ -webkit-font-smoothing: antialiased;
}
-input[type=checkbox] + label:before { content: '\f096'; }
-input[type=checkbox] + label:before { letter-spacing: 10px; }
+input[type=checkbox] + label:before {
+ font-family: Font Awesome\ 5 Free;
+ letter-spacing: 10px;
+ content: '\f0c8';
+}
-input[type=checkbox]:checked + label:before { content: '\f046'; }
-input[type=checkbox]:checked + label:before { letter-spacing: 8px; }
+input[type=checkbox]:checked + label:before {
+ font-family: Font Awesome\ 5 Free;
+ letter-spacing: 10px;
+ content: '\f14a';
+}
#code {
color: #aaa;
diff --git a/views/share.erb b/views/share.erb
@@ -22,7 +22,7 @@
justify-content: center;
}
body > div {
- padding: 0 5px 15px 5px;
+ padding: 0 40px 20px 40px;
}
h3 {
margin: 10px 0;
@@ -112,8 +112,24 @@
$('i').click(() => {
const text = $('#share').text();
$('input').val(text);
- $('input')[0].select();
+ const elem = $('input')[0];
+ const range = document.createRange();
+
+ elem.contentEditable = true;
+ elem.readOnly = false;
+ range.selectNodeContents(elem);
+
+ const s = window.getSelection();
+ s.removeAllRanges();
+ s.addRange(range);
+
+ elem.setSelectionRange(0, 999999);
+
+ if (!navigator.userAgent.match(/ipad|ipod|iphone/i)) {
+ elem.select();
+ }
document.execCommand("copy");
+
$('i span').text('Copied!');
setTimeout(() => $('i span').text('Copy to Clipboard.'), 700);
});