Merge remote-tracking branch 'origin/master' into shim-webcrypto

This commit is contained in:
Danny Coates 2017-08-04 14:44:11 -07:00
commit 02fc4d74db
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
21 changed files with 204 additions and 40 deletions

View file

@ -25,6 +25,11 @@ if (storage.has('referrer')) {
window.referrer = 'external';
}
const allowedCopy = () => {
const support = !!document.queryCommandSupported;
return support ? document.queryCommandSupported('copy') : false;
};
$(document).ready(function() {
gcmCompliant()
.then(function() {
@ -76,22 +81,23 @@ $(document).ready(function() {
// copy link to clipboard
$copyBtn.click(() => {
// record copied event from success screen
sendEvent('sender', 'copied', {
cd4: 'success-screen'
});
copyToClipboard($('#link').attr('value'));
//disable button for 3s
$copyBtn.attr('disabled', true);
$('#link').attr('disabled', true);
$copyBtn.html(
'<img src="/resources/check-16.svg" class="icon-check"></img>'
);
window.setTimeout(() => {
$copyBtn.attr('disabled', false);
$('#link').attr('disabled', false);
$copyBtn.attr('data-l10n-id', 'copyUrlFormButton');
}, 3000);
if (allowedCopy() && copyToClipboard($('#link').attr('value'))) {
// record copied event from success screen
sendEvent('sender', 'copied', {
cd4: 'success-screen'
});
//disable button for 3s
$copyBtn.attr('disabled', true);
$('#link').attr('disabled', true);
$copyBtn.html(
'<img src="/resources/check-16.svg" class="icon-check"></img>'
);
window.setTimeout(() => {
$copyBtn.attr('disabled', false);
$('#link').attr('disabled', false);
$copyBtn.attr('data-l10n-id', 'copyUrlFormButton');
}, 3000);
}
});
$('.upload-window').on('dragover', () => {
@ -343,7 +349,8 @@ $(document).ready(function() {
const $copyIcon = $('<img>', {
src: '/resources/copy-16.svg',
class: 'icon-copy',
'data-l10n-id': 'copyUrlHover'
'data-l10n-id': 'copyUrlHover',
disabled: !allowedCopy()
});
const expiry = document.createElement('td');
const del = document.createElement('td');

View file

@ -127,12 +127,12 @@ function copyToClipboard(str) {
sel.removeAllRanges();
sel.addRange(range);
aux.setSelectionRange(0, str.length);
}
else {
} else {
aux.select();
}
document.execCommand('copy');
const result = document.execCommand('copy');
document.body.removeChild(aux);
return result;
}
const ONE_DAY_IN_MS = 86400000;