//jQuery time
var current_fs, next_fs, previous_fs; //fieldsets
var left, opacity, scale; //fieldset properties which we will animate
var animating; //flag to prevent quick multi-click glitches
// Add event listener for 'next' button click
$(".next").click(function() {
if (animating) return false;
animating = true;
current_fs = $(this).parent();
if ($(this).attr('name') == 'feveryes')
next_fs = $('#feveryes');
if ($(this).attr('name') == 'feverno')
next_fs = $('#feverno');
if ($(this).attr('name') == 'coughyes')
next_fs = $('#coughyes');
if ($(this).attr('name') == 'coughno')
next_fs = $('#coughno');
if ($(this).attr('name') == 'previous')
next_fs = $('#firstField');
$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
next_fs.show();
current_fs.animate({
opacity: 0
}, {
step: function(now, mx) {
scale = 1 - (1 - now) * 0.2;
left = (now * 50) + "%";
opacity = 1 - now;
next_fs.css({
'left': left,
'opacity': opacity
});
},
duration: 800,
complete: function() {
current_fs.hide();
animating = false;
},
easing: 'easeInOutBack'
});
});
// Add event listener for 'previous' button click
$(".previous").click(function() {
if (animating) return false;
animating = true;
current_fs = $(this).parent();
previous_fs = $('#firstField');
$("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
previous_fs.show();
current_fs.animate({
opacity: 0
}, {
step: function(now, mx) {
scale = 0.8 + (1 - now) * 0.2;
left = ((1 - now) * 50) + "%";
opacity = 1 - now;
current_fs.css({
'left': left
});
previous_fs.css({
'transform': 'scale(' + scale + ')',
'opacity': opacity
});
},
duration: 800,
complete: function() {
current_fs.hide();
animating = false;
},
easing: 'easeInOutBack'
});
});
// Add event listener for 'submit' button click
$(".submit").click(function() {
return false;
});
/*custom font*/
@import url(http://fonts.googleapis.com/css?family=Montserrat);
/*basic reset*/
* {
margin: 0;
padding: 0;
}
html {
height: 100%;
background: url('http://thecodeplayer.com/uploads/media/gs.png');
background: linear-gradient(rgba(196, 102, 0, 0.2), rgba(155, 89, 182, 0.2)), url('http://thecodeplayer.com/uploads/media/gs.png');
}
body {
font-family: montserrat, arial, verdana;
overflow-x: hidden;
}
/*form styles*/
#msform {
width: 100%;
margin: 50px auto;
text-align: center;
position: relative;
}
#msform fieldset {
background: white;
border: 0 none;
border-radius: 3px;
box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4);
padding: 20px 30px;
box-sizing: border-box;
width: 80%;
margin: 0 10%;
position: absolute;
}
#msform fieldset:not(:first-of-type) {
display: none;
}
#msform img {
width: 80%;
}
#msform input,
#msform textarea {
padding: 15px;
border: 1px solid #ccc;
border-radius: 3px;
margin-bottom: 10px;
width: 100%;
box-sizing: border-box;
font-family: montserrat;
color: #2C3E50;
font-size: 13px;
}
#msform .action-button {
width: 100px;
background: #27AE60;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 1px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
#msform .action-button:hover,
#msform .action-button:focus {
box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60;
}
... (truncated for brevity) ...
</script>
<script src="http://thecodeplayer.com/uploads/js/jquery.easing.min.js"></script>
<form id="msform">
<fieldset id="firstField">
<h2 class="fs-title">Do you have a fever?</h2>
<input type="button" name="feveryes" class="next action-button" value="Yes" />
<input type="button" name="feverno" class="next action-button" value="No" />
<br><input type="button" name="previous" class="previous action-button" value="Reset" />
</fieldset>
<fieldset id="feveryes">
<h2 class="fs-title">Do you have a cough? Do you have a cough? Do you have a cough? ... </h2><br><img src="https://upload.wikimedia.org/wikipedia/en/thumb/6/63/IMG_(business).svg/1280px-IMG_(business).svg.png">
<input type="button" name="coughyes" class="next action-button" value="Yes" />
<input type="button" name="coughno" class="next action-button" value="No" />
<br><input type="button" name="previous" class="previous action-button" value="Reset" />
</fieldset>
... (truncated for brevity) ...
</form>