-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Survey Aesthetics #124
Survey Aesthetics #124
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,60 @@ | |
<script type="text/javascript" src="/static/vendor/js/vue-2.5.17.min.js"></script> | ||
<script type="text/javascript" src="/static/vendor/vue-form-generator-2.3.4/vfg.js"></script> | ||
<link rel="stylesheet" type="text/css" href="/static/vendor/vue-form-generator-2.3.4/vfg.css"> | ||
<style type="text/css"> | ||
.vue-form-generator .field-radios .radio-list label { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that this catches labels in groups of radio buttons, should similar style be set for groups of checkboxes? (See Do you eat a specialized diet ? (select all that apply), Step 2 of 7 in the Microsetta Participant Survey) Rough guess on the css selector is: Could be a separate change entirely though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you thinking you'd want to have the checkbox options span the entire width of the screen (similar to radio buttons), rather than in a one-per-line dropdown? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dhakim87 is this a blocking item or can this be sorted out later? |
||
padding-right: 25px; | ||
display: inline-block; | ||
} | ||
|
||
.survey-nav-button { | ||
padding: 6px 12px; | ||
color: #ffffff!important; | ||
background-color: #337ab7!important; | ||
border: 1px solid #cccccc; | ||
border-radius: 4px; | ||
font-size: 14px; | ||
font-weight: 400; | ||
line-height: 1.42857143; | ||
text-align: center; | ||
display: none; | ||
} | ||
|
||
.form-group label span{ | ||
font-weight: 700; | ||
} | ||
|
||
.form-group { | ||
padding-bottom: 5px; | ||
} | ||
|
||
.field-wrap { | ||
font-size: 90%; | ||
} | ||
|
||
#form-progress { | ||
width: 100%; | ||
text-align: center; | ||
display: none; | ||
font-weight: bold; | ||
} | ||
</style> | ||
<script> | ||
var result_txt = ""; | ||
var error_txt = ""; | ||
var form_submitted = 0; | ||
|
||
function postSurvey() { | ||
fieldsetObject = document.getElementsByTagName("fieldset"); | ||
cassidysymons marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// workaround to make the first six sections of the survey visible to the DOM so they submit, but hidden to the user | ||
for(i=1; i<(fieldsetObject.length-1); i++) { | ||
fieldsetObject[i].style.position = "absolute"; | ||
fieldsetObject[i].style.top = "-9999px"; | ||
fieldsetObject[i].style.left = "-9999px"; | ||
fieldsetObject[i].style.display = "inline-block"; | ||
} | ||
|
||
$.ajax({ | ||
type: "POST", | ||
url: "{{ endpoint }}/accounts/{{ account_id }}/sources/{{ source_id }}/take_survey?survey_template_id={{ survey_template_id }}", | ||
|
@@ -65,14 +114,16 @@ | |
<li class="breadcrumb-item active" aria-current="page">Participant Survey</li> | ||
{% endblock %} | ||
{% block content %} | ||
<div id="form-progress">Progress</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-body"> | ||
<form id="survey_form" name="survey_form"> | ||
<vue-form-generator :schema="schema" :model="model" :options="formOptions"></vue-form-generator> | ||
</form> | ||
</div> | ||
<input type="button" id="survey-nav-button-previous" class="survey-nav-button" value="<< Previous Section" onClick="changePage('previous');"> | ||
<input type="button" id="survey-nav-button-next" class="survey-nav-button" value="Next Section >>" onClick="changePage('next');"> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
var survey_model = {}; | ||
var survey_schema= {{survey_schema|tojson}}; | ||
|
@@ -94,10 +145,68 @@ | |
type: "submit", | ||
validateBeforeSubmit: true, | ||
onSubmit: function(){ | ||
$("input").prop('disabled', true); | ||
return postSurvey(); | ||
if(form_submitted == 0) { | ||
confirm_submit = confirm("Please note: Once you've submitted this survey, you'll be unable to edit your answers. If you'd like to review or change any of your responses, please press the Cancel button. Otherwise, press OK to submit your responses."); | ||
cassidysymons marked this conversation as resolved.
Show resolved
Hide resolved
|
||
form_submitted = 1; | ||
} else { | ||
confirm_submit = true; | ||
} | ||
|
||
if(confirm_submit == true) { | ||
$("input").prop('disabled', true); | ||
return postSurvey(); | ||
} | ||
} | ||
}); | ||
|
||
var active_section = 0; | ||
|
||
function paginateForm() { | ||
fieldsetObject = document.getElementsByTagName("fieldset"); | ||
|
||
if(fieldsetObject.length <= 1) { | ||
document.getElementById("survey-nav-button-next").style.display = "none"; | ||
} else { | ||
document.getElementById("form-progress").style.display = "block"; | ||
document.getElementById("form-progress").innerHTML = "Step 1 of " + fieldsetObject.length + " - 0% Complete"; | ||
for(i=1; i<fieldsetObject.length; i++) { | ||
cassidysymons marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fieldsetObject[i].style.display = "none"; | ||
} | ||
document.getElementById("survey-nav-button-next").style.display = "inline-block"; | ||
} | ||
} | ||
|
||
function changePage(direction) { | ||
if(direction == "next") { | ||
new_active_section = active_section + 1; | ||
} else { | ||
new_active_section = active_section - 1; | ||
} | ||
display_active_section = new_active_section+1; | ||
|
||
fieldsetObject = document.getElementsByTagName("fieldset"); | ||
|
||
fieldsetObject[active_section].style.display = "none"; | ||
document.getElementById("form-progress").innerHTML = "Step " + display_active_section + " of " + fieldsetObject.length + " - " + Math.round((new_active_section/fieldsetObject.length)*100) + "% Complete"; | ||
fieldsetObject[new_active_section].style.display = "block"; | ||
|
||
if(new_active_section == 0) { | ||
document.getElementById("survey-nav-button-previous").style.display = "none"; | ||
} else { | ||
document.getElementById("survey-nav-button-previous").style.display = "inline-block"; | ||
} | ||
if(new_active_section == (fieldsetObject.length-1)) { | ||
document.getElementById("survey-nav-button-next").style.display = "none"; | ||
} else { | ||
document.getElementById("survey-nav-button-next").style.display = "inline-block"; | ||
} | ||
|
||
window.scrollTo(0,0); | ||
active_section = new_active_section; | ||
} | ||
|
||
$(paginateForm); | ||
</script> | ||
<script type="text/javascript" src="/static/vue_survey_form.js"></script> | ||
{% endblock %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a bunch of the spans use class="red right required-field", I'm guessing class red just sets color: red. Should we bundle the definition of right into here also, then we can just set class="required-field" everywhere and drop the red and right classes from all the spans?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "red" and "right" classes were already in the code but didn't appear to be doing anything. I added the required-field class to handle the aesthetic changes I was making, but left red and right in place in case there was some legacy reason for them that I was unaware of.
If there's no reason to keep them, I'd be happy to clean them all out and just keep required-field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, so spans are required-field, divs are red right required-field? I think my question is can we drop the red class from the divs (assuming the right class does something else we want that isn't covered)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, both the red and right classes can be dropped from the divs. Neither class is defined anywhere in the CSS and I don't see any JavaScript that uses them. If neither you nor @wasade know of any reasons to keep them, I can drop both and just leave required-field in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say drop them then, if nothing shifts around or changes color, we're in the clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just dropped all of the references to the red and right classes and standardized all of the asterisks to . I double-checked after the change and nothing was altered visually, either in color or positioning.