fade away resolved error messages on questions

This commit is contained in:
Mark Moser 2016-08-04 09:38:27 -05:00
parent ac3c992ba5
commit f8f471fba3
6 changed files with 35 additions and 14 deletions

View File

@ -1,17 +1,29 @@
var $textInput = $('[type="color"], [type="date"], [type="datetime"], [type="datetime-local"], [type="email"], [type="month"], [type="number"], [type="password"], [type="search"], [type="tel"], [type="text"], [type="time"], [type="url"], [type="week"], input:not([type]), textarea');
// Text Input Label Animation // Text Input Label Animation
$textInput.prev('label').addClass('loaded');
var textInput = $('[type="color"], [type="date"], [type="datetime"], [type="datetime-local"], [type="email"], [type="month"], [type="number"], [type="password"], [type="search"], [type="tel"], [type="text"], [type="time"], [type="url"], [type="week"], input:not([type]), textarea'); $textInput.each(function() {
textInput.prev('label').addClass('loaded');
$(textInput).each(function() {
if( $(this).val() ) { if( $(this).val() ) {
$(this).prev('label').addClass('animate'); $(this).prev('label').addClass('animate');
} }
}); });
$(textInput).on('focus', function() { $textInput.on('focus', function() {
$(this).prev('label').addClass('animate'); $(this).prev('label').addClass('animate');
}).on('focusout', function() { }).on('focusout', function() {
if( !$(this).val() ) { if( !$(this).val() ) {
$(this).prev('label').removeClass('animate'); $(this).prev('label').removeClass('animate');
} }
}); });
// form error resolutions
$('form').has('.error').each(function(){
var $form = $(this);
$form.on('keyup', $textInput, function(){
$form.find(".error").addClass('resolve-error');
});
$form.on('change', $("[type=radio], [type=checkbox]"), function(){
$form.find(".error").addClass('resolve-error');
});
});

View File

@ -16,7 +16,10 @@
@import 'base'; // bitters @import 'base'; // bitters
@import 'neat'; @import 'neat';
@import 'core/**/*'; @import 'core/fonts';
@import 'core/variables';
@import 'core/animations';
@import 'atoms/**/*'; @import 'atoms/**/*';
@import 'molecules/**/*'; @import 'molecules/**/*';
// @import 'organisms/**/*'; // @import 'organisms/**/*';

View File

@ -0,0 +1,5 @@
@keyframes success-fadeout {
0% { opacity: 1; max-height: 40px; }
85% { opacity: 0; max-height: 40px; padding: .5rem 0; margin-bottom: .5rem; }
100% { opacity: 0; max-height: 0; padding: 0; margin-bottom: 0; }
}

View File

@ -266,6 +266,13 @@ select {
margin-top: 2rem; margin-top: 2rem;
} }
.resolve-error {
animation-name: success-fadeout;
animation-duration: 1.5s;
animation-delay: 0;
animation-fill-mode: forwards;
}
html.no-js { html.no-js {
.chars { .chars {
display: none; display: none;

View File

@ -43,12 +43,6 @@
margin-top: 3rem; margin-top: 3rem;
} }
@keyframes success-fadeout {
0% { opacity: 1; max-height: 40px; }
85% { opacity: 0; max-height: 40px; padding: .5rem 0; margin-bottom: .5rem; }
100% { opacity: 0; max-height: 0; padding: 0; margin-bottom: 0; }
}
.success { .success {
box-sizing: border-box; box-sizing: border-box;
text-align: center; text-align: center;