an ios friendly copy
This commit is contained in:
parent
fb41a40128
commit
b93a33eba4
@ -2,6 +2,7 @@
|
|||||||
require('./common');
|
require('./common');
|
||||||
const FileSender = require('./fileSender');
|
const FileSender = require('./fileSender');
|
||||||
const {
|
const {
|
||||||
|
copyToClipboard,
|
||||||
notify,
|
notify,
|
||||||
gcmCompliant,
|
gcmCompliant,
|
||||||
findMetric,
|
findMetric,
|
||||||
@ -79,12 +80,7 @@ $(document).ready(function() {
|
|||||||
sendEvent('sender', 'copied', {
|
sendEvent('sender', 'copied', {
|
||||||
cd4: 'success-screen'
|
cd4: 'success-screen'
|
||||||
});
|
});
|
||||||
const aux = document.createElement('input');
|
copyToClipboard($('#link').attr('value'));
|
||||||
aux.setAttribute('value', $('#link').attr('value'));
|
|
||||||
document.body.appendChild(aux);
|
|
||||||
aux.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
document.body.removeChild(aux);
|
|
||||||
//disable button for 3s
|
//disable button for 3s
|
||||||
$copyBtn.attr('disabled', true);
|
$copyBtn.attr('disabled', true);
|
||||||
$('#link').attr('disabled', true);
|
$('#link').attr('disabled', true);
|
||||||
@ -392,12 +388,7 @@ $(document).ready(function() {
|
|||||||
sendEvent('sender', 'copied', {
|
sendEvent('sender', 'copied', {
|
||||||
cd4: 'upload-list'
|
cd4: 'upload-list'
|
||||||
});
|
});
|
||||||
const aux = document.createElement('input');
|
copyToClipboard(url);
|
||||||
aux.setAttribute('value', url);
|
|
||||||
document.body.appendChild(aux);
|
|
||||||
aux.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
document.body.removeChild(aux);
|
|
||||||
document.l10n.formatValue('copiedUrl').then(translated => {
|
document.l10n.formatValue('copiedUrl').then(translated => {
|
||||||
link.innerHTML = translated;
|
link.innerHTML = translated;
|
||||||
});
|
});
|
||||||
|
@ -114,9 +114,31 @@ function sendEvent() {
|
|||||||
.catch(() => 0);
|
.catch(() => 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copyToClipboard(str) {
|
||||||
|
const aux = document.createElement('input');
|
||||||
|
aux.setAttribute('value', str);
|
||||||
|
aux.contentEditable = true;
|
||||||
|
aux.readOnly = true;
|
||||||
|
document.body.appendChild(aux);
|
||||||
|
if (navigator.userAgent.match(/iphone|ipad|ipod/i)) {
|
||||||
|
const range = document.createRange();
|
||||||
|
range.selectNodeContents(aux);
|
||||||
|
const sel = window.getSelection();
|
||||||
|
sel.removeAllRanges();
|
||||||
|
sel.addRange(range);
|
||||||
|
aux.setSelectionRange(0, str.length);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aux.select();
|
||||||
|
}
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.body.removeChild(aux);
|
||||||
|
}
|
||||||
|
|
||||||
const ONE_DAY_IN_MS = 86400000;
|
const ONE_DAY_IN_MS = 86400000;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
copyToClipboard,
|
||||||
arrayToHex,
|
arrayToHex,
|
||||||
hexToArray,
|
hexToArray,
|
||||||
notify,
|
notify,
|
||||||
|
Loading…
Reference in New Issue
Block a user