updated password input UI

This commit is contained in:
Danny Coates 2018-02-16 12:56:53 -08:00
parent 8d41111cd6
commit 346e604f34
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
37 changed files with 282 additions and 288 deletions

View file

@ -3,10 +3,13 @@ const passwordInput = require('../passwordInput');
module.exports = function(state, emit) {
const file = state.storage.getFileById(state.params.id);
const div = html`
return html`
<div class="setPasswordSection">
<div class="checkbox">
<input
${file.hasPassword ? 'disabled' : ''}
${file.hasPassword ? 'checked' : ''}
class="checkbox__input"
id="add-password"
type="checkbox"
@ -16,22 +19,9 @@ module.exports = function(state, emit) {
${state.translate('requirePasswordCheckbox')}
</label>
</div>
${passwordInput(
state.translate('unlockInputPlaceholder'),
state.translate('addPasswordButton'),
addPassword
)}
${passwordInput(file, state, emit)}
</div>`;
function addPassword(event) {
event.preventDefault();
const password = document.getElementById('password-input').value;
if (password.length > 0) {
emit('password', { password, file });
}
return false;
}
function togglePasswordInput(e) {
const unlockInput = document.getElementById('password-input');
const boxChecked = e.target.checked;
@ -44,6 +34,4 @@ module.exports = function(state, emit) {
unlockInput.value = '';
}
}
return div;
};