Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.

Commit

Permalink
Merge pull request #608 from mozilla/link-copy
Browse files Browse the repository at this point in the history
disable copying link when password not completed
  • Loading branch information
ericawright committed Oct 30, 2017
2 parents b0307e9 + f814427 commit a31f6b7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app/templates/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ module.exports = function(state, emit) {
input.disabled = true;
const copyBtn = document.getElementById('copy-btn');
copyBtn.disabled = true;
copyBtn.classList.add('success');
copyBtn.replaceChild(
html`<img src="${assets.get('check-16.svg')}" class="icon-check">`,
copyBtn.firstChild
);
await delay(2000);
input.disabled = false;
copyBtn.disabled = false;
if (!copyBtn.parentNode.classList.contains('wait-password')) {
copyBtn.disabled = false;
}
copyBtn.classList.remove('success');
copyBtn.textContent = state.translate('copyUrlFormButton');
}
}
Expand Down
15 changes: 14 additions & 1 deletion app/templates/uploadPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,27 @@ module.exports = function(state, emit) {
</form>
</div>`;

function togglePasswordInput() {
function togglePasswordInput(e) {
const unlockInput = document.getElementById('unlock-input');
const boxChecked = e.target.checked;
document.querySelector('.setPassword').classList.toggle('hidden');
document
.getElementById('copy')
.classList.toggle('wait-password', boxChecked);
document.getElementById('copy-btn').disabled = boxChecked;
if (boxChecked) {
unlockInput.focus();
} else {
unlockInput.value = '';
}
}

function setPassword(event) {
event.preventDefault();
const password = document.getElementById('unlock-input').value;
if (password.length > 0) {
document.getElementById('copy').classList.remove('wait-password');
document.getElementById('copy-btn').disabled = false;
emit('password', { password, file });
}
}
Expand Down
12 changes: 10 additions & 2 deletions assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ tbody {
width: 100%;
}

#copy.wait-password #link,
#copy.wait-password #copy-btn {
opacity: 0.5;
}

#copy-text {
align-self: flex-start;
margin-top: 60px;
Expand Down Expand Up @@ -596,13 +601,16 @@ tbody {
white-space: nowrap;
}

#copy-btn:hover {
#copy-btn:not(:disabled):hover {
background-color: #0287e8;
}

#copy-btn:disabled {
#copy-btn.success {
background: #05a700;
border: 1px solid #05a700;
}

#copy-btn:disabled {
cursor: auto;
}

Expand Down

0 comments on commit a31f6b7

Please sign in to comment.