Browse Source

Fixed labels on inputs when autosomplete is used

development
Godwin 9 years ago
parent
commit
a099059f2e
  1. 18
      app/assets/javascripts/main.js
  2. 11
      app/assets/stylesheets/_application.scss

18
app/assets/javascripts/main.js

@ -18,19 +18,25 @@
field.classList[input.value ? 'remove' : 'add']('empty'); field.classList[input.value ? 'remove' : 'add']('empty');
} }
positionLabel(input); positionLabel(input);
input.addEventListener('keyup', function(event) { positionLabel(event.target); }); input.addEventListener('keyup', function(event) {
input.addEventListener('blur', function(event) { field.classList.remove('focused'); }); positionLabel(event.target);
input.addEventListener('focus', function(event) { field.classList.add('focused'); }); });
input.addEventListener('blur', function(event) {
positionLabel(event.target);
field.classList.remove('focused');
});
input.addEventListener('focus', function(event) {
field.classList.add('focused');
});
}); });
var body = document.querySelector('body'); var body = document.querySelector('body');
var primaryContent = document.getElementById('primary-content'); var primaryContent = document.getElementById('primary-content');
var overlay = document.getElementById('content-overlay'); var overlay = document.getElementById('content-overlay');
primaryContent.addEventListener('keydown', function(event) { primaryContent.addEventListener('keydown', function(event) {
if (body.classList.contains('has-overlay')) {
event.stopPropagation(); event.stopPropagation();
return false; return false;
//if (body.classList.contains('has-overlay')) { }
// return false;
//}
}); });
document.addEventListener('focus', function(event) { document.addEventListener('focus', function(event) {
if (overlay.querySelector('.dlg.open') && !overlay.querySelector('.dlg.open :focus')) { if (overlay.querySelector('.dlg.open') && !overlay.querySelector('.dlg.open :focus')) {

11
app/assets/stylesheets/_application.scss

@ -2333,7 +2333,6 @@ html[data-lingua-franca-example="html"] {
} }
@include breakpoint(medium) { @include breakpoint(medium) {
html[data-input="kb"] {
:focus, :focus,
input[type="submit"]:focus, input[type="submit"]:focus,
.check-box-field input:focus + label, .check-box-field input:focus + label,
@ -2341,11 +2340,19 @@ html[data-lingua-franca-example="html"] {
.select-field select:focus, .select-field select:focus,
.workshop-link:focus .title, .workshop-link:focus .title,
#main-nav .nav a:focus .title { #main-nav .nav a:focus .title {
outline: 0.25rem solid rgba($colour-2, 0.5); html & {
outline: 0.25rem solid rgba($colour-2, 0);
outline-offset: 0.2rem; outline-offset: 0.2rem;
@include _(transition, outline 150ms ease-in-out);
}
html[data-input="kb"] & {
outline: 0.25rem solid rgba($colour-2, 0.5);
z-index: 1; z-index: 1;
} }
}
html[data-input="kb"] {
#main-nav .logo:focus { #main-nav .logo:focus {
outline-offset: -0.2em; outline-offset: -0.2em;
} }

Loading…
Cancel
Save