this.dropdown = this.quiz.screens.getActiveScreen().find(".dropdown")
//
- $(document).on("click", "label[for=toggleDropdown]", function() {
+ $(document).on("click", "label[for=toggleDropdown]", function () {
$this.dropdown.addClass("active")
})
//
- $(document).on("click", ".country", function() {
+ $(document).on("click", ".country", function () {
$this.dropdown.removeClass("active")
let value = $(this).text()
- $(".active-screen input").val(value)
+ $(".active-screen input").val(value);
+ $(this).closest('form').trigger('change');
})
this.setScrollBarDropdown()
},
- setScrollBarDropdown: function() {
+ setScrollBarDropdown: function () {
let dp = new SimpleBar(this.dropdown.get(0))
},
// Cliquer sur le bouton suivant
$(document).on("click", ".active-screen.next .action", function () {
- if($this.getActiveScreenType() === 'email') {
- if(!$this.validateEmail($this.activeScreen.find("input").val())) {
- alert('Please enter a correct format');
+ if ($this.getActiveScreenType() === 'email') {
+ if (!$this.validateEmail($this.activeScreen.find("input").val())) {
+ $this.activeScreen.find("input").addClass('error');
return false;
}
}
if (($this.currentQuestionAnswers.length === 0 && !parseInt($this.quiz.question.current().countdown_enable)) || (parseInt($this.quiz.question.current().countdown_enable) && $this.intervalCountDown !== 0 && $this.currentQuestionAnswers.length === 0)) {
- alert('Please select at least one answer');
+ $this.activeScreen.find("input[type='email'],input[type='text'],textarea,.dropdown").addClass('error');
return false;
}
if ($(this).hasClass('validate')) {
let review = $this.sendUserAnswers();
// Si la revue instantanée est activée, on affiche les résultats
- if ($this.quiz.data.instantReview && !['country','email','text'].includes($this.getActiveScreenType()) ) {
+ if ($this.quiz.data.instantReview && !['country', 'email', 'text'].includes($this.getActiveScreenType())) {
$this.instantReview(review);
} else {
// Sinon, on passe directement à la question suivante
const $this = this;
this.currentQuestionAnswers = []
- if(['country','email','text'].includes(this.getActiveScreenType())) {
+ if (['country', 'email', 'text'].includes(this.getActiveScreenType())) {
this.currentQuestionAnswers = this.getActiveScreen().find(".answer-text").val()
} else {
$(".active-screen form").find("input:checked").each(function () {
if ($this.getActiveScreenType() === 'draganddrop') {
$this.quiz.draganddrop.start()
- } else if($this.getActiveScreenType() === 'match') {
+ } else if ($this.getActiveScreenType() === 'match') {
$this.quiz.match.start()
- } else if($this.getActiveScreenType() === 'country') {
+ } else if ($this.getActiveScreenType() === 'country') {
$this.quiz.countriesList.start()
- } else if($this.getActiveScreenType() === 'email') {
+ } else if ($this.getActiveScreenType() === 'email') {
$this.email = $this.activeScreen.find("input").val()
}
this.getCurrentForm().find("input").prop("checked", false)
} else if (type === 'draganddrop') {
this.quiz.draganddrop.reset();
- } else if(type === 'match') {
+ } else if (type === 'match') {
this.quiz.match.reset();
} else {
this.getCurrentForm().find(".answer-text").val("")
document.documentElement.style.setProperty("--width-bg-countdown", "100%")
},
- validateEmail: function(email) {
- let re = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
+ validateEmail: function (email) {
+ let re = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
return re.test(email);
}
};
top: 50%
transform: translateY(-50%)
z-index: 3
- input:focus+svg
+
+ input:focus + svg
color: $texts-color
.form-group
input,
textarea,
.dropdown
+ font-family: $font
width: 100%
+radius(16px)
padding: 20px 16px
color: $texts-color
outline: none
box-sizing: border-box
+
&::placeholder
+opacity(.48, color, $texts-color)
opacity: 1
&::-ms-input-placeholder
+opacity(.48, color, $texts-color)
+ &.error
+ border-color: $nok-color
+
textarea
height: 183px
opacity: 0
visibility: hidden
z-index: 2
+
&.active
max-height: 325px
opacity: 1
&.placeholder
padding-top: 0
- color: rgba($texts-color,.48)
+ color: rgba($texts-color, .48)
.country
- border-top: 1px solid rgba($texts-color,.16)
+ border-top: 1px solid rgba($texts-color, .16)
// SimpleBar personalisation
.simplebar-track
<div class="container-screen none" data-screen="q-{{$position}}" data-type="country">
- @include('components.background',['data'=>$data,'name'=>'standard','fit'=>'fill'])
+ @include('components.background',['data'=>$data, 'name'=>'standard', 'fit'=>'fill'])
<div class="fill-area"></div>
@include('header_question', ['question' =>$question, 'max' => $max, 'position' => $position])
<div class="screen question-text question-country">
<form id="form-{{$position}}">
<div class="form-group">
<label for="toggleDropdown">
- <input class="answer-text" id="toggleDropdown" name="text" placeholder="{{$__('Select an answer')}}" type="text" />
- <svg class="arrow" xmlns="http://www.w3.org/2000/svg" width="18.828" height="10.414" viewBox="0 0 18.828 10.414">
+ <input class="answer-text" id="toggleDropdown" name="answer"
+ placeholder="{{$question['placeholder']?:$__('Choose a country')}}" type="text"/>
+ <svg class="arrow" xmlns="http://www.w3.org/2000/svg" width="18.828" height="10.414"
+ viewBox="0 0 18.828 10.414">
<g id="Groupe_87" data-name="Groupe 87" transform="translate(17.414 -14.086) rotate(90)">
- <path id="Tracé_50" data-name="Tracé 50" d="M11.5,5l8,8-8,8" transform="translate(4 -5)" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/>
+ <path id="Tracé_50" data-name="Tracé 50" d="M11.5,5l8,8-8,8" transform="translate(4 -5)"
+ fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
+ stroke-width="2"/>
</g>
</svg>
</label>
<div class="dropdown">
<ul class="countrylist">
- <li class="placeholder">{{$__("Select an answer")}}</li>
+ <li class="placeholder">{{$question['placeholder']?:$__('Choose a country')}}</li>
@foreach($data["countriesList"] as $key => $name)
<li class="country" data-key="{{$key}}">{{$name}}</li>
@endforeach
<div class="screen question-text question-email">
<form id="form-{{$position}}">
<div class="form-group">
- <input class="answer-text" name="email" type="email" placeholder="{{$__('Enter your email')}}..." />
+ <input class="answer-text" name="answer" type="email" placeholder="{{$question['placeholder']?:$__('Your email')}}" />
<svg xmlns="http://www.w3.org/2000/svg" width="17.6" height="15.6" viewBox="0 0 17.6 15.6">
<g id="Groupe_487" data-name="Groupe 487" transform="translate(-5299.2 240.8)">
<rect id="Rectangle_206" data-name="Rectangle 206" width="16" height="14" rx="3" transform="translate(5300 -240)" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.6"/>
<div class="screen question-text">
<form id="form-{{$position}}">
<div class="form-group">
- <input class="answer-text" name="text" type="text" placeholder="{{$__('Enter your answer')}}..."/>
+ <input class="answer-text" name="answer" type="text" placeholder="{{$question['placeholder']?:''}}"/>
</div>
</form>
</div>
<div class="screen question-text">
<form id="form-{{$position}}">
<div class="form-group">
- <textarea class="answer-text" name="textarea" rows="10" placeholder="{{$__('Enter your answer')}}..."></textarea>
+ <textarea class="answer-text" name="answer" rows="10" placeholder="{{$question['placeholder']?:''}}"></textarea>
</div>
</form>
</div>