PageSourceSearch

https://thefamilyshed.com/wp-content/plugins/quiz-maker/public/js/quiz-maker-public.js?ver=1790979578

js thefamilyshed.com collected 2026-10-02 22:21:07 UTC 211,117 bytes, 3,588 lines download raw bytes

1(function ($) {
2    'use strict';
3    $(document).ready(function () {
4        $.fn.goTo = function(myOptions) {
5            var QuizAnimationTop = (myOptions.quiz_animation_top && myOptions.quiz_animation_top != 0) ? parseInt(myOptions.quiz_animation_top) : 100;
6
7            myOptions.quiz_enable_animation_top = myOptions.quiz_enable_animation_top ? myOptions.quiz_enable_animation_top : 'on';
8            var EnableQuizAnimationTop = ( myOptions.quiz_enable_animation_top && myOptions.quiz_enable_animation_top == 'on' ) ? true : false;
9            if( EnableQuizAnimationTop ){
10                $('html, body').animate({
11                    scrollTop: $(this).offset().top - QuizAnimationTop + 'px'
12                }, 'slow');
13            }
14            return this; // for chaining...
15        }
16        if (!String.prototype.trim) {
17            (function() {
18                String.prototype.trim = function() {
19                    return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
20                };
21            })();
22        }
23
24        $(document).find('.for_quiz_rate_avg.ui.rating').rating('disable');
25
26        var ays_quiz_container, ays_quiz_container_id, quizId; //flag to prevent quick multi-click glitches
27        var myOptions, myQuizOptions, explanationTimeout;
28        var emailValivatePattern = /^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+\.\w{2,}$/;
29        var aysThisQuizBullets = null;
30        if( typeof window.aysQuizBullets == 'undefined' ){
31            window.aysQuizBullets = [];
32        }
33        
34        if( typeof window.aysSeeResultConfirmBox == 'undefined' ){
35            window.aysSeeResultConfirmBox = [];
36        }
37
38        if( typeof window.aysEarlyFinishConfirmBox == 'undefined' ){
39            window.aysEarlyFinishConfirmBox = [];
40        }
41
42
43        window.aysTimerInterval = null;
44
45        function time_limit(e) {
46            quizId = $(e.target).parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
47            myOptions = JSON.parse(atob(window.aysQuizOptions[quizId]));
48
49            if(checkQuizPassword(e, myOptions, false) === false){
50                return false;
51            }
52
53            if(typeof myOptions.answers_rw_texts == 'undefined'){
54                myOptions.answers_rw_texts = 'on_passing';
55            }
56            if(typeof myOptions.make_questions_required == 'undefined'){
57                myOptions.make_questions_required = 'off';
58            }
59            var quizOptionsName = 'quizOptions_'+quizId;
60            myQuizOptions = [];
61            if(typeof window[quizOptionsName] !== 'undefined'){
62                for(var i in window[quizOptionsName]){
63                    myQuizOptions[i] = (JSON.parse(window.atob(window[quizOptionsName][i])));
64                }
65            }
66            
67            if(typeof window.aysSeeResultConfirmBox !== 'undefined'){
68                window.aysSeeResultConfirmBox[ quizId ] = false;
69            }
70
71            if(typeof window.aysEarlyFinishConfirmBox !== 'undefined'){
72                window.aysEarlyFinishConfirmBox[ quizId ] = false;
73            }
74
75            var container = $(e.target).parents('.ays-quiz-container');
76            if ($(this).parents('.step').next().find('.information_form').length === 0 ){
77                var quizMusic = container.find('audio.ays_quiz_music');
78                if(quizMusic.length !== 0){                
79                    var soundEls = $(document).find('.ays_music_sound');
80                    container.find('.ays_music_sound').removeClass('ays_display_none');
81                    if(!isPlaying(quizMusic.get(0))){
82                        container.find('audio.ays_quiz_music')[0].play();
83                        audioVolumeIn($(e.target).parents('.ays-quiz-container').find('audio.ays_quiz_music')[0]);
84                    }
85                }
86                container.find('.ays-live-bar-wrap').css({'display': 'block'});
87                container.find('.ays-live-bar-percent').css({'display': 'inline-block'});
88                container.find('input.ays-start-date').val(GetFullDateTime());
89            }
90            if ($(this).parents('.step').next().find('.information_form').length === 0 && myOptions.enable_timer == 'on') {
91                container.find('div.ays-quiz-timer').hide(800);
92                var timer = parseInt(container.find('div.ays-quiz-timer').attr('data-timer'));
93                var pageTitle = $(document).find('title');
94                var pageTitleText = $(document).find('title').html();
95                var timeForShow = "";
96
97                // Display all questions on one page
98                myOptions.quiz_timer_red_warning = ( myOptions.quiz_timer_red_warning ) ? myOptions.quiz_timer_red_warning : 'off';
99                var quiz_timer_red_warning = (myOptions.quiz_timer_red_warning && myOptions.quiz_timer_red_warning == "on") ? true : false;
100
101                if (!isNaN(timer) && myOptions.timer !== undefined) {
102                    if (myOptions.timer === timer && timer !== 0) {
103                        timer += 2;
104                        if (timer !== undefined) {
105                            var countDownDate = new Date().getTime() + (timer * 1000);
106                            var timerFlag = false;
107
108                            // Message before timer
109                            var quiz_message_before_timer = (myOptions.quiz_message_before_timer && myOptions.quiz_message_before_timer != "") ? ( myOptions.quiz_message_before_timer ) : '';
110
111                            if ( quiz_message_before_timer != '' ) {
112                                quiz_message_before_timer = quiz_message_before_timer.replace(/(["'])/g, "\\$1") + " ";
113                                $(document).find('html > head').append('<style> #ays-quiz-container-'+ quizId +' div.ays-quiz-timer.ays-quiz-message-before-timer:before{content: "'+ quiz_message_before_timer +'"; }</style>');
114                            }
115
116                            window.aysTimerInterval = setInterval(function () {
117                                var now = new Date().getTime();
118                                var distance = countDownDate - Math.ceil(now/1000)*1000;
119                                var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
120                                var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
121                                var seconds = Math.floor((distance % (1000 * 60)) / 1000);
122                                var sec = seconds;
123                                var min = minutes;
124                                var hour = hours;
125                                if(hours <= 0){
126                                    hours = null;
127                                }else if (hours < 10) {
128                                    hours = '0' + hours;
129                                }
130                                if (minutes < 10) {
131                                    minutes = '0' + minutes;
132                                }
133                                if (seconds < 10) {
134                                    seconds = '0' + seconds;
135                                }
136                                timeForShow =  ((hours==null)? "" : (hours + ":")) + minutes + ":" + seconds;
137                                if(distance <=1000){
138                                    timeForShow =  ((hours==null) ? "" : "00:") + "00:00";
139                                    container.find('div.ays-quiz-timer').html(timeForShow);
140                                    if(myOptions.quiz_timer_in_title == 'on'){
141                                        pageTitle.html( timeForShow + " - " + pageTitleText );
142                                    }
143                                }else{
144                                    container.find('div.ays-quiz-timer').html(timeForShow);
145                                    if(myOptions.quiz_timer_in_title == 'on'){
146                                        pageTitle.html( timeForShow + " - " + pageTitleText );
147                                    }
148                                }
149                                
150                                if ( quiz_timer_red_warning ) {
151                                    var distanceSec = Math.floor(distance / 1000);
152                                    var timerPercentage = Math.floor(( timer - distanceSec ) * 100);
153                                    var percentage = Math.floor( timerPercentage / timer );
154
155                                    if ( percentage >= 90 && ! timerFlag ) {
156                                        var timerContainer = container.find('section.ays_quiz_timer_container');
157                                        timerFlag = true;
158
159                                        if ( ! timerContainer.hasClass( 'ays_quiz_timer_red_warning' ) ) {
160                                            timerContainer.addClass( 'ays_quiz_timer_red_warning' );
161                                        }
162                                    }
163                                }
164
165                                container.find('.ays_quiz_timer_container').show();
166                                container.find('div.ays-quiz-timer').show(500);
167                                if(container.find('.ays-quiz-timer').length === 0){
168                                    clearInterval(window.aysTimerInterval);
169                                    if(myOptions.quiz_timer_in_title == 'on'){
170                                        pageTitle.html( pageTitleText );
171                                    }
172                                    container.find('.ays_quiz_timer_container').slideUp(500);
173                                }
174                                if(container.find('.ays_finish.action-button').hasClass("ays_timer_end") ||
175                                   container.find('.ays_next.action-button').hasClass("ays_timer_end")){
176                                    clearInterval(window.aysTimerInterval);
177                                    if(myOptions.quiz_timer_in_title == 'on'){
178                                        pageTitle.html( pageTitleText );
179                                    }
180                                    container.find('.ays_quiz_timer_container').slideUp(500);
181                                }
182
183                                if(hour == 0 && min == 0 && sec < 1){
184                                    container.find('.ays_buttons_div > *:not(input.ays_finish)').off('click');
185                                }
186
187                                if (distance <= 1) {
188                                    clearInterval(window.aysTimerInterval);
189                                    if(! container.find('div.ays-quiz-after-timer').hasClass('empty_after_timer_text')){
190                                        container.find('.ays_quiz_timer_container').css({
191                                            'position': 'static',
192                                            'height': '100%',
193                                        });
194                                        container.find('.ays_quiz_timer_container').show();
195                                        container.find('div.ays-quiz-timer').slideUp();
196                                        container.find('div.ays-quiz-after-timer').addClass("ays-quiz-timer-end");
197                                        container.find('div.ays-quiz-after-timer').slideDown(500);
198                                    }else{
199                                        container.find('.ays_quiz_timer_container').slideUp(500);
200                                    }
201
202                                    if(myOptions.quiz_timer_in_title == 'on'){
203                                        pageTitle.html( pageTitleText );
204                                    }
205                                    var totalSteps = container.find('div.step').length;
206                                    var currentStep = container.find('div.step.active-step');
207                                    var thankYouStep = container.find('div.step.ays_thank_you_fs');
208                                    var infoFormLast = thankYouStep.prev().find('div.information_form');
209                                    if(infoFormLast.length == 0){
210                                        if (currentStep.hasClass('ays_thank_you_fs') === false) {
211                                            var steps = totalSteps - 3;
212                                            container.find('div.step').each(function (index) {
213                                                if ($(this).hasClass('ays_thank_you_fs')) {
214                                                    $(this).addClass('active-step')
215                                                }else{
216                                                    $(this).css('display', 'none');                                                
217                                                }
218                                            });
219                                            // aysAnimateStep(ays_quiz_container.data('questEffect'), currentStep, ays_quiz_container.find('.step.ays_thank_you_fs'));
220                                            var ays_finish_button = container.find('input.ays_finish');
221                                            if(ays_finish_button.prop('disabled')){
222                                                ays_finish_button.prop('disabled', false);
223                                            }
224                                            ays_finish_button.addClass('ays-quiz-after-timer-end');
225                                            ays_finish_button.trigger('click');
226                                        }
227                                    }else{
228                                        if(container.find('div.ays-quiz-after-timer').hasClass('empty_after_timer_text')){
229                                            container.find('.ays-quiz-timer').parent().slideUp(500);
230                                        }
231                                        container.find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut');
232                                        container.find('.ays-live-bar-percent').removeClass('rubberBand').addClass('bounceOut');
233                                        setTimeout(function () {
234                                            container.find('.ays-live-bar-wrap').css('display','none');
235                                            container.find('.ays-live-bar-percent').css('display','none');
236                                        },300);
237                                        aysAnimateStep(ays_quiz_container.data('questEffect'), currentStep, infoFormLast.parent());
238                                        container.find('div.step').each(function (index) {
239                                            $(this).css('display', 'none');
240                                            $(this).removeClass('active-step')
241                                        });
242                                        infoFormLast.parent().addClass('active-step'); 
243                                    }
244                                    container.parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').slide
244Up(500);
245                                }
246                            }, 1000);
247                        }
248                    } else {
249                        alert('Wanna cheat??');
250                        window.location.reload();
251                    }
252                }
253
254            }else{
255                $(this).parents('.step').next().find('.information_form').find('.ays_next.action-button').on('click', function () {
256                    if($(this).parents('.step').find('.information_form').find('.ays_next.action-button').hasClass('ays_start_allow')){
257                        time_limit(e);                        
258                    }
259                });
260            }
261        }
262        
263        $(document).find('.ays_next.start_button').on('click', time_limit);
264        
265        $(document).find('.ays_next.start_button').on('click', function(e){
266
267            if (typeof $(this).attr("data-enable-leave-page") !== 'undefined') {
268                $(this).attr("data-enable-leave-page",true);
269            }
270
271            if(checkQuizPassword(e, myOptions, false) === false){
272                return false;
273            }
274
275            ays_quiz_container_id = $(this).parents(".ays-quiz-container").attr("id");
276            ays_quiz_container = $('#'+ays_quiz_container_id);
277            
278            aysResetQuiz( ays_quiz_container );
279
280            ays_quiz_container.css('padding-bottom', '0px');
281            var ancnoxneriQanak = $(this).parents('.ays-questions-container').find('.ays_quizn_ancnoxneri_qanak');
282            var aysQuizReteAvg = $(this).parents('.ays-questions-container').find('.ays_quiz_rete_avg');
283            var next_sibilings_count = $(this).parents('form').find('.ays_question_count_per_page').val();
284            
285            var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
286            if(isRequiredQuestion === true && !( parseInt( next_sibilings_count ) > 0 ) ){
287                ays_quiz_container.find('div[data-question-id]').each(function(){
288                    var thisStep = $(this);
289                    if(!thisStep.find('input.ays_next').hasClass('ays_display_none')){
290                        thisStep.find('input.ays_next').attr('disabled', 'disabled');
291                    }else if(!thisStep.find('i.ays_next_arrow').hasClass('ays_display_none')){
292                        thisStep.find('i.ays_next_arrow').attr('disabled', 'disabled');
293                    }
294
295                    if(!thisStep.find('input.ays_early_finish').hasClass('ays_display_none')){
296                        thisStep.find('input.ays_early_finish').attr('disabled', 'disabled');
297                    }else if(!thisStep.find('i.ays_early_finish').hasClass('ays_display_none')){
298                        thisStep.find('i.ays_early_finish').attr('disabled', 'disabled');
299                    }
300                });
301            }
302
303            if( ays_quiz_container.find('.enable_min_selection_number').length > 0 ){
304                ays_quiz_container.find('.enable_min_selection_number').each(function(){
305                    var thisStep = $(this).parents('.step');
306                    thisStep.find('input.ays_next').attr('disabled', 'disabled');
307                    thisStep.find('i.ays_next_arrow').attr('disabled', 'disabled');
308
309                    thisStep.find('input.ays_early_finish').attr('disabled', 'disabled');
310                    thisStep.find('i.ays_early_finish').attr('disabled', 'disabled');
311                });
312            }
313
314            ays_quiz_container.find('div[data-question-id][data-type="custom"]').each(function(){
315                $(this).find('i.ays_clear_answer').addClass('ays_display_none');
316                $(this).find('input.ays_clear_answer').addClass('ays_display_none');
317            });
318
319            setTimeout(function(){
320                ays_quiz_container.css('border-radius', myOptions.quiz_border_radius + 'px');
321                ays_quiz_container.find('.step').css('border-radius', myOptions.quiz_border_radius + 'px');
322            }, 400);
323            
324            aysAnimateStep(ays_quiz_container.data('questEffect'), aysQuizReteAvg);
325            aysAnimateStep(ays_quiz_container.data('questEffect'), ancno
325xneriQanak);
326            
327            if ($(this).parents('.step').next().find('.information_form').length === 0 ){
328
329            $(this).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').slideDown(500);
330                var questions_count = $(this).parents('form').find('div[data-question-id]').length;
331                var curent_number = $(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]')) + 1;
332                if(questions_count <= parseInt(next_sibilings_count)){
333                    next_sibilings_count = questions_count;
334                }
335                if(parseInt(next_sibilings_count) > 0 &&
336                   ($(this).parents('.step').attr('data-question-id') || 
337                    $(this).parents('.step').next().attr('data-question-id'))){
338                    var final_width = ((parseInt(next_sibilings_count)) / questions_count * 100) + "%";
339                    if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
340                        $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(parseInt(next_sibilings_count)));
341                    }else{                
342                        $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width));
343                    }
344                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
345                }else{
346                    var final_width = ((curent_number+1) / questions_count * 100) + "%";
347                    if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
348                        $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+1));
349                    }else{                
350                        $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width));
351                    }
352                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
353                }
354            }
355
356            if ( ays_quiz_container.hasClass('ays_quiz_hide_bg_on_start_page') ) {
357                ays_quiz_container.removeClass('ays_quiz_hide_bg_on_start_page');
358            }
359
360            aysQuizBullets[quizId] = createPagination($(this).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap'), 1);
361            aysThisQuizBullets = aysQuizBullets[quizId];
362            aysThisQuizBullets._navPage(0);
363
364        });
365
366        $(document).on('focus', '.ays-quiz-container input', function () {
367            $(window).on('keydown', function (event) {
368                if (event.keyCode === 13) {
369                    return false;
370                }
371            });
372        });
373
374        $(document).on('blur', '.ays-quiz-container input', function () {
375            $(window).off('keydown');
376        });
377        
378        $.each($(document).find('.ays_block_content'), function () {
379            if ($(document).find('.ays_block_content').length != 0) {
380                var ays_block_element = $(this).parents().eq(2);
381                ays_block_element.find('input.ays-start-date').val(GetFullDateTime());
382                ays_block_element.find('div.ays-quiz-timer').slideUp(500);
383                var timer = parseInt(ays_block_element.find('div.ays-quiz-timer').attr('data-timer'));
384                var timerInTitle = ays_block_element.find('div.ays-quiz-timer').data('showInTitle');
385                var tabTitle = document.title;
386                setTimeout(function(){
387                if (timer !== NaN) {
388                    timer += 2;
389                    if (timer !== undefined) {
390                        var countDownDate = new Date().getTime() + (timer * 1000);
391                        var x = setInterval(function () {
392                            var now = new Date().getTime();
393                            var distance = countDownDate - Math.ceil(now/1000)*1000;
394                            var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
395                            var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
396                            var seconds = Math.floor((distance % (1000 * 60)) / 1000);
397                            var timeForShow = "";
398                            if(hours <= 0){
399                                hours = null;
400                            }else if (hours < 10) {
401                                hours = '0' + hours;
402                            }
403                            if (minutes < 10) {
404                                minutes = '0' + minutes;
405                            }
406                            if (seconds < 10) {
407                                seconds = '0' + seconds;
408                            }
409                            timeForShow =  ((hours==null)? "" : (hours + ":")) + minutes + ":" + seconds;
410                            if(distance <=1000){
411                                timeForShow = ((hours==null) ? "" : "00:") + "00:00";
412                                ays_block_element.find('div.ays-quiz-timer').html(timeForShow);
413                                if(timerInTitle){
414                                    document.title = timeForShow + " - " + tabTitle ;
415                                }
416                            }else{
417                                ays_block_element.find('div.ays-quiz-timer').html(timeForShow);
418                                if(timerInTitle){
419                                    document.title = timeForShow + " - " + tabTitle ;
420                                }
421                            }
422                            ays_block_element.find('div.ays-quiz-timer').slideDown(500);
423                            var ays_block_element_redirect_url = ays_block_element.find('.ays_redirect_url').text();
424                            if (distance <= 1) {
425                                clearInterval(x);
426                                var totalSteps = ays_block_element.find('div.step').length;
427                                var currentStep = ays_block_element.eq(2).find('div.step.active-step');
428                                var currentStepIndex = ays_block_element.eq(2).find('div.step.active-step').index();
429                                if (currentStep.hasClass('ays_thank_you_fs') === false) {
430                                    var steps = totalSteps - 3;
431                                    ays_block_element.find('div.step').each(function (index) {
432                                        if (index >= (currentStepIndex - 1) && index <= steps) {
433                                            $(this).remove();
434                                        }
435                                    });
436                                    window.location = ays_block_element_redirect_url;
437                                }
438                            }
439                        }, 1000);
440                    }
441                }
442                }, 1000);
443            }
444        });
445        
446        $(document).find('button.ays_check_answer').on('click', function (e) {
447            var thisAnswerOptions;
448            var quizContainer = $(e.target).parents('.ays-quiz-container');
449            var right_answer_sound = quizContainer.find('.ays_quiz_right_ans_sound').get(0);
450            var wrong_answer_sound = quizContainer.find('.ays_quiz_wrong_ans_sound').get(0);
451            var questionId = $(this).parents('.step').data('questionId');
452            var finishAfterWrongAnswer = (myOptions.finish_after_wrong_answer && myOptions.finish_after_wrong_answer == "on") ? true : false;
453            var showOnlyWrongAnswer = (myOptions.show_only_wrong_answer && myOptions.show_only_wrong_answer == "on") ? true : false;
454            var explanationTime = myOptions.explanation_time && myOptions.explanation_time != "" ? parseInt(myOptions.explanation_time) : 4;
455            var next_sibilings_count = quizContainer.find('.ays_question_count_per_page').val();
456            var enableNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == 'on') ? true : false;
457            var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
458
459            // Display all questions on one page
460            myOptions.quiz_display_all_questions = ( myOptions.quiz_display_all_questions ) ? myOptions.quiz_display_all_questions : 'off';
461            var quiz_display_all_questions = (myOptions.quiz_display_all_questions && myOptions.quiz_display_all_questions == "on") ? true : false;
462
463            var disableQuestions = false;
464            if( parseInt( next_sibilings_count ) > 0 || quiz_display_all_questions == true ){
465                disableQuestions = true;
466            }
467
468            thisAnswerOptions = myQuizOptions[questionId];
469            if($(this).parent().find('.ays-text-input').val() !== ""){
470                if ($(e.target).parents('form[id^="ays_finish_quiz"]').hasClass('enable_correction')) {
471                    if($(e.target).parents('.step').hasClass('not_influence_to_score')){
472                        return false;
473                    }
474                    $(this).css({
475                        animation: "bounceOut .5s",
476                    });
477                    setTimeout(function(){
478                        $(e.target).parent().find('.ays-text-input').css('width', '100%');
479                        $(e.target).css("display", "none");
480                    },480);
481                    $(e.target).parent().find('.ays-text-input').css('background-color', '#eee');
482                    $(this).parent().find('.ays-text-input').attr('disabled', 'disabled');
483                    $(this).attr('disabled', 'disabled');
484                    $(this).off('change');
485                    $(this).off('click');
486                    $(this).parents('.ays-field').addClass('ays-answered-text-input');
487
488                    var input = $(this).parent().find('.ays-text-input');
489                    var type = input.attr('type');
490                    var userAnsweredText = input.val().trim();
491
492                    // Enable case sensitive text
493                    var enable_case_sensitive_text = (thisAnswerOptions.enable_case_sensitive_text && thisAnswerOptions.enable_case_sensitive_text != "") ? thisAnswerOptions.enable_case_sensitive_text : false;
494
495                    var trueAnswered = false;
496                    var thisQuestionAnswer = aysEscapeHtmlDecode( thisAnswerOptions.question_answer ).aysStripSlashes().toLowerCase();
497                    var displayingQuestionAnswer = thisAnswerOptions.question_answer;
498
499                    if( type == 'text' || type == 'short_text' ){
500                        if ( enable_case_sensitive_text ) {
501                            thisQuestionAnswer = aysEscapeHtmlDecode( thisAnswerOptions.question_answer ).aysStripSlashes();
502                        }
503                    }
504
505                    if(type == 'date'){
506                        var correctDate = new Date(thisAnswerOptions.question_answer),
507                            correctDateYear = correctDate.getFullYear(),
508                            correctDateMonth = correctDate.getMonth(),
509                            correctDateDay = correctDate.getDate();
510                        var userDate = new Date(userAnsweredText),
511                            userDateYear = userDate.getFullYear(),
512                            userDateMonth = userDate.getMonth(),
513                            userDateDay = userDate.getDate();
514                        if(correctDateYear == userDateYear && correctDateMonth == userDateMonth && correctDateDay == userDateDay){
515                            trueAnswered = true;
516                        }
517                    }else if(type != 'number'){
518                        thisQuestionAnswer = thisQuestionAnswer.split('%%%');
519                        displayingQuestionAnswer = displayingQuestionAnswer.split('%%%');
520                        for(var i = 0; i < thisQuestionAnswer.length; i++){
521                            if ( enable_case_sensitive_text ) {
522                                if(userAnsweredText == thisQuestionAnswer[i].trim()){
523                                    trueAnswered = true;
524                                    break;
525                                }
526                            } else {
527                                if(userAnsweredText.toLowerCase() == thisQuestionAnswer[i].trim()){
528                                    trueAnswered = true;
529                                    break;
530                                }
531                            }
532                        }
533                    }else{
534                        if(userAnsweredText.toLowerCase() == thisQuestionAnswer.trim()){
535                            trueAnswered = true;
536                        }
537                    }
538
539                    if(trueAnswered){
540                        if((right_answer_sound)){
541                            resetPlaying([right_answer_sound, wrong_answer_sound]);
542                            setTimeout(function(){
543                                right_answer_sound.play();
544                            }, 10);
545                        }
546                        $(this).parent().find('.ays-text-input').css('background-color', 'rgba(39,174,96,0.5)');
547                        $(this).parent().find('input[name="ays_answer_
547correct[]"]').val(1);
548                        if(! $(this).parents('.step').hasClass('not_influence_to_score')){
549                            $(this).parents('.step').find('.right_answer_text').slideDown(250);
550                        }
551
552                        if( aysThisQuizBullets !== null ){
553                            var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
554                            var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
555                            thisBullet.attr('disabled', 'disabled');
556                            thisBullet.addClass('ays_quiz_correct_answer');
557                            thisBullet.parent().addClass('ays_quiz_checked_answer_div');
558                        }
559                    }else{
560                        if((wrong_answer_sound)){
561                            resetPlaying([right_answer_sound, wrong_answer_sound]);
562                            setTimeout(function(){
563                                wrong_answer_sound.play();
564                            }, 10);
565                        }
566                        $(this).parent().find('.ays-text-input').css('background-color', 'rgba(243,134,129,0.8)');
567                        $(this).parent().find('input[name="ays_answer_correct[]"]').val(0);
568
569                        if( aysThisQuizBullets !== null ){
570                            var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
571                            var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
572                            thisBullet.attr('disabled', 'disabled');
573                            thisBullet.addClass('ays_quiz_wrong_answer');
574                            thisBullet.parent().addClass('ays_quiz_checked_answer_div');
575                        }
576                        if(showOnlyWrongAnswer === false){
577                            var rightAnswerText = '<div class="ays-text-right-answer">';
578
579                            if(type == 'date'){
580                                var correctDate = new Date(thisAnswerOptions.question_answer),
581                                    correctDateYear = correctDate.getFullYear(),
582                                    correctDateMonth = (correctDate.getMonth() + 1) < 10 ? "0"+(correctDate.getMonth() + 1) : (correctDate.getMonth() + 1),
583                                    correctDateDay = (correctDate.getDate() < 10) ? "0"+correctDate.getDate() : correctDate.getDate();
584                                rightAnswerText += [correctDateMonth, correctDateDay, correctDateYear].join('/');
585                            }else if(type != 'number'){
586                                // rightAnswerText += thisQuestionAnswer[0];
587                                rightAnswerText += displayingQuestionAnswer[0];
588                            }else{
589                                // rightAnswerText += thisQuestionAnswer;
590                                rightAnswerText += displayingQuestionAnswer;
591                            }
592
593                            rightAnswerText += '</div>';
594                            $(this).parents('.ays-quiz-answers').append(rightAnswerText);
595                            $(this).parents('.ays-quiz-answers').find('.ays-text-right-answer').slideDown(500);
596                        }
597
598                        if(! $(this).parents('.step').hasClass('not_influence_to_score')){
599                            $(this).parents('.step').find('.wrong_answer_text').slideDown(250);
600                        }
601
602                        if(finishAfterWrongAnswer){
603                            $(this).parents('div[data-question-id]').find('.ays_next').attr('disabled', 'disabled');
604                            $(this).parents('div[data-question-id]').find('.ays_early_finish').attr('disabled', 'disabled');
605                            $(this).parents('div[data-question-id]').find('.ays_previous').attr('disabled', 'disabled');
606                            if( disableQuestions ){
607                                quizContainer.find('div[data-question-id]').css('pointer-events', 'n
607one');
608                            }
609                            explanationTimeout = setTimeout(function(){
610                                goToLastPage(e);
611                            }, explanationTime * 1000);
612                        }
613                        if(finishAfterWrongAnswer){
614                            if( aysThisQuizBullets !== null ){
615                                aysThisQuizBullets.baseElement.find('.ays_questions_nav_question').each(function(){
616                                    var thisBullet = $(this);
617                                    thisBullet.attr('disabled', 'disabled');
618                                });
619                            }
620                        }
621                    }
622                    var showExplanationOn = (myOptions.show_questions_explanation && myOptions.show_questions_explanation != "") ? myOptions.show_questions_explanation : "on_results_page";
623                    if(showExplanationOn == 'on_passing' || showExplanationOn == 'on_both'){
624                        if(! $(this).parents('.step').hasClass('not_influence_to_score')){
625                            $(this).parents('.step').find('.ays_questtion_explanation').slideDown(250);
626                        }
627                    }
628
629                    explanationTimeout = setTimeout(function(){
630                        if ( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
631                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
632                            if ( existsEmtpyQuestions ) {
633                                quizContainer.find('input.ays_finish').trigger('click');
634                            }
635                        }
636                    }, explanationTime * 1000);
637                }
638            }
639        });
640
641        $(document).find('textarea.ays_question_limit_length, input.ays_question_limit_length').on('keyup keypress', function(e) {
642            var $this = $(this);
643            var questionId = $this.attr('data-question-id');
644            var container = $this.parents('.ays-field').next('.ays_quiz_question_text_conteiner');
645            var box = container.find('.ays_quiz_question_text_message');
646            var questionTextMessage = container.find('.ays_quiz_question_text_message_span');
647
648            if (questionId !== null && questionId != '') {
649
650                // Maximum length of a text field
651                var enable_question_text_max_length = (myQuizOptions[questionId].enable_question_text_max_length && myQuizOptions[questionId].enable_question_text_max_length != "") ? myQuizOptions[questionId].enable_question_text_max_length : false;
652
653                // Length
654                var question_text_max_length = (myQuizOptions[questionId].question_text_max_length && myQuizOptions[questionId].question_text_max_length != "") ? parseInt(myQuizOptions[questionId].question_text_max_length) : '';
655
656                // Limit by
657                var question_limit_text_type = (myQuizOptions[questionId].question_limit_text_type && myQuizOptions[questionId].question_limit_text_type != "") ? myQuizOptions[questionId].question_limit_text_type : 'characters';
658
659                // Show word/character counter
660                var question_enable_text_message = (myQuizOptions[questionId].question_enable_text_message && myQuizOptions[questionId].question_enable_text_message != '') ? myQuizOptions[questionId].question_enable_text_message : false;
661
662                var remainder = '';
663                if(question_text_max_length != '' && question_text_max_length != 0){
664                    switch ( question_limit_text_type ) {
665                        case 'characters':
666                            var tval = $this.val();
667                            var tlength = tval.length;
668                            var set = question_text_max_length;
669                            var remain = parseInt(set - tlength);
670                            if (remain <= 0 && e.which !== 0 && e.charCode !== 0) {
671                                $this.val((tval).substring(0, tlength - 1));
672                            }
673                            if (e.type=="keyup") {
674                                var tval = $this.val().trim();
675                                if(tval.length > 0 && tval != null){
676                                    var wordsLength = this.value.split('').length;
677                                    if (wordsLength > question_text_max_length) {
678                                        var trimmed = tval.split('', question_text_max_length).join("");
679                                        $this.val(trimmed);
680                                    }
681                                }
682                            }
683                            remainder = remain;
684                            break;
685                        case 'words':
686                            if (e.type=="keyup") {
687                                var tval = $this.val().trim();
688                                if(tval.length > 0 && tval != null){
689                                    var wordsLength = this.value.match(/\S+/g).length;
690                                    if (wordsLength > question_text_max_length) {
691                                        var trimmed = tval.split(/\s+/, question_text_max_length).join(" ");
692                                        $this.val(trimmed + " ");
693                                    }
694                                    remainder = question_text_max_length - wordsLength;
695                                }
696                            }
697                            break;
698                        default:
699                            break;
700                    }
701                    if (e.type=="keyup") {
702                        if ( question_enable_text_message ) {
703                            if(question_text_max_length != '' && question_text_max_length != 0){
704                                if (remainder <= 0) {
705                                    remainder = 0;
706                                    if (! box.hasClass('ays_quiz_question_text_error_message') ) {
707                                        box.addClass('ays_quiz_question_text_error_message')
708                                    }
709                                }else{
710                                    if ( box.hasClass('ays_quiz_question_text_error_message') ) {
711                                        box.removeClass('ays_quiz_question_text_error_message')
712                                    }
713                                }
714                                if (tval.length == 0 || tval == null) {
715                                    if ( box.hasClass('ays_quiz_question_text_error_message') ) {
716                                        box.removeClass('ays_quiz_question_text_error_message')
717                                    }
718                                    remainder = question_text_max_length;
719                                }
720
721                                questionTextMessage.html( remainder );
722                            }
723                        }
724                    }
725                }
726            }
727        });
728
729        $(document).on('click', '.enable_max_selection_number input[type="checkbox"]', function(e) {
730            var $this = $(this);
731
732            var parent = $this.parents('.step');
733            var questionId = parent.attr('data-question-id');
734            questionId = parseInt( questionId );
735
736            var checkedCount = parent.find('.ays-field input[type="checkbox"]:checked').length;
737
738            if (questionId !== null && questionId != '' && typeof myQuizOptions[questionId] != 'undefined') {
739
740                // Maximum length of a text field
741                var enable_max_selection_number = (myQuizOptions[questionId].enable_max_selection_number && myQuizOptions[questionId].enable_max_selection_number != "") ? myQuizOptions[questionId].enable_max_selection_number : false;
742
743                // Length
744                var max_selection_number = (myQuizOptions[questionId].max_selection_number && myQuizOptions[questionId].max_selection_number != "") ? parseInt(myQuizOptions[questionId].max_selection_number) : '';
745
746                if( enable_max_selection_number === true && max_selection_number != '' ){
747
748                    if( max_selection_number < checkedCount ){
749                        return false;
750                    }
751                }
752            }
753
754        });
755
756        $(document).on('click', '.enable_min_selection_number input[type="checkbox"]', function(e) {
757            var $this = $(this);
758            var this_current_fs = $this.parents('.step[data-question-id]');
759            var enableArrows = $this.parents(".ays-questions-container").find(".ays_qm_enable_arrows").val();
760            var questions = $(this).parents('form').find('.step[data-question-id]');
761            var next_sibilings_count = $(this).parents('form').find('.ays_question_count_per_page').val();
762            var current_fs_indexes = [];
763
764            var thisIndex = 0;
765            for( var j = 0; j < Math.floor( questions.length / parseInt( next_sibilings_count ) ); j++ ){
766                thisIndex += parseInt( next_sibilings_count );
767                current_fs_indexes.push( thisIndex - 1 );
768            }
769
770            var thisStepIndex = 0;
771            var thisQuestionStepIndex = questions.index( $this.parents('.step[data-question-id]') );
772            for( var k = 0; k < current_fs_indexes.length; k++ ){
773                if( thisQuestionStepIndex <= current_fs_indexes[k] ){
774                    thisStepIndex = current_fs_indexes[k];
775                    break;
776                }
777            }
778
779            if( thisStepIndex == 0 ){
780                thisStepIndex = questions.length - 1;
781            }
782
783            var current_fs_index = questions.index( questions.eq( thisStepIndex ) );
784
785            // Display all questions on one page
786            myOptions.quiz_display_all_questions = ( myOptions.quiz_display_all_questions ) ? myOptions.quiz_display_all_questions : 'off';
787            var quiz_display_all_questions = (myOptions.quiz_display_all_questions && myOptions.quiz_display_all_questions == "on") ? true : false;
788
789            if ( quiz_display_all_questions ) {
790                next_sibilings_count = questions.length;
791            }
792
793
794            var buttonsDiv = $(this).parents('form').find('.step[data-question-id]').eq( thisStepIndex ).find('.ays_buttons_div');
795            if($(this).parents('.step').attr('data-question-id')){
796                if( parseInt( next_sibilings_count ) > 0 && ( $(this).parents('.step').attr('data-question-id') || $(this).parents('.step').next().attr('data-question-id') ) ){
797                    var sliceStart = current_fs_index - parseInt( next_sibilings_count ) < 0 ? 0 : current_fs_index - parseInt( next_sibilings_count ) + 1;
798                    this_current_fs = questions.slice( sliceStart, current_fs_index + 1 );
799                }else{
800                    this_current_fs = $(this).parents('.step[data-question-id]');
801                    buttonsDiv = this_current_fs.find('.ays_buttons_div');
802                }
803            }else{
804                this_current_fs = $(this).parents('.step[data-question-id]');
805                buttonsDiv = this_current_fs.find('.ays_buttons_div');
806            }
807
808            this_current_fs.each(function(){
809                var checkedMinSelCount = aysCheckMinimumCountCheckbox( $(this), myQuizOptions );
810
811                if( ays_quiz_is_question_min_count( $(this), !checkedMinSelCount ) === true ){
812                    if( checkedMinSelCount == true ){
813                        if(enableArrows){
814                            buttonsDiv.find('i.ays_next_arrow').removeAttr('disabled');
815                            buttonsDiv.find('i.ays_next_arrow').prop('disabled', false);
816                            buttonsDiv.find('i.ays_early_finish').prop('disabled', false);
817                        }else{
818                            buttonsDiv.find('input.ays_next').removeAttr('disabled');
819                            buttonsDiv.find('input.ays_next').prop('disabled', false);
820                            buttonsDiv.find('input.ays_early_finish').prop('disabled', false);
821                        }
822                    }else{
823                        if(enableArrows){
824                            buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
825                            buttonsDiv.find('i.ays_next_arrow').prop('disabled', true);
826                            buttonsDiv.find('i.ays_early_finish').prop('disabled', true);
827                        }else{
828                            buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
829                            buttonsDiv.find('input.ays_next').prop('disabled', true);
830                            buttonsDiv.find('input.ays_early_finish').prop('disabled', true);
831                        }
832                    }
833                }else{
834                    if(enableArrows){
835                        buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
836                        buttonsDiv.find('i.ays_next_arrow').prop('disabled', true);
837                        buttonsDiv.find('i.ays_early_finish').prop('disabled', true);
838                    }else{
839                        buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
840                        buttonsDiv.find('input.ays_next').prop('disabled', true);
841                        buttonsDiv.find('input.ays_early_finish').prop('disabled', true);
842                        return false;
843                    }
844                }
845            });
846        });
847
848        $(document).find('input.ays_question_number_limit_length').on('keyup keypress', function(e) {
849            var $this = $(this);
850            var questionId = $this.parents('.step[data-question-id]').attr('data-question-id');
851            var parent = $this.parents('.ays-abs-fs');
852
853            if (questionId !== null && questionId != '') {
854                var questionOptions = myQuizOptions[questionId];
855
856                // Maximum length of a number field
857                var enable_question_number_max_length = (questionOptions.enable_question_number_max_length && questionOptions.enable_question_number_max_length != "") ? questionOptions.enable_question_number_max_length : false;
858
859                // Length
860                var question_number_max_length = (typeof questionOptions.question_number_max_length != 'undefined' && questionOptions.question_number_max_length !== "") ? parseInt(questionOptions.question_number_max_length) : '';
861
862                // Minimum length of a number field
863                var enable_question_number_min_length = (questionOptions.enable_question_number_min_length && questionOptions.enable_question_number_min_length != "") ? questionOptions.enable_question_number_min_length : false;
864
865                // Length
866                var question_number_min_length = (typeof questionOptions.question_number_min_length != 'undefined' && questionOptions.question_number_min_length !== "") ? parseInt(questionOptions.question_number_min_length) : '';
867
868                // Show error message
869                var enable_question_number_error_message = (questionOptions.enable_question_number_error_message && questionOptions.enable_question_number_error_message != "") ? questionOptions.enable_question_number_error_message : false;
870
871                // Message
872                var question_number_error_message = (questionOptions.question_number_error_message && questionOptions.question_number_error_message != "") ? questionOptions.question_number_error_message : '';
873
874                if ( enable_question_number_max_length ) {
875                    if(question_number_max_length !== ''){
876                        var tval = $this.val().trim();
877                        var inputVal = parseInt( tval );
878
879                        if( ! isNaN(inputVal) ){
880                            if ( inputVal > question_number_max_length ) {
881                                $this.val(question_number_max_length);
882                            }
883
884                            if (e.type=="keyup") {
885                                if ( inputVal > question_number_max_length ) {
886                                    $this.val(question_number_max_length);
887                                }
888                            }
889                        }
890                    }
891                }
892
893                if ( enable_question_number_min_length ) {
894                    if(question_number_min_length !== ''){
895                        var tval = $this.val().trim();
896                        var inputVal = parseInt( tval );
897                        if( ! isNaN(inputVal) ){
898                            if ( inputVal < question_number_min_length ) {
899                                $this.val(question_number_min_length);
900                            }
901
902                            if (e.type=="keyup") {
903                                if ( inputVal < question_number_min_length ) {
904                                    $this.val(question_number_min_length);
905                                }
906                            }
907                        }
908                    }
909                }
910
911                if ( enable_question_number_error_message ) {
912                    if ( question_number_error_message != "" ) {
913                        var tval = $this.val().trim();
914                        var inputVal = tval;
915
916                        var errorMessageBox = parent.find('.ays-quiz-number-error-message');
917
918                        if ( tval != "" ) {
919
920                            if ( isNaN( +inputVal ) ) {
921                                if ( errorMessageBox.hasClass('ays_display_none') ) {
922                                    errorMessageBox.removeClass('ays_display_none');
923                                }
924                            } else if ( tval.indexOf("e") > -1 ) {
925                                if ( errorMessageBox.hasClass('ays_display_none') ) {
926                                    errorMessageBox.removeClass('ays_display_none');
927                                }
928                            } else if ( tval.slice(-1) == "e" ) {
929                                if ( errorMessageBox.hasClass('ays_display_none') ) {
930                                    errorMessageBox.removeClass('ays_display_none');
931                                }
932                            } else {
933                                if ( ! errorMessageBox.hasClass('ays_display_none') ) {
934                                    errorMessageBox.addClass('ays_display_none');
935                                }
936                            }
937                        } else {
938                            if ( ! errorMessageBox.hasClass('ays_display_none') ) {
939                                errorMessageBox.addClass('ays_display_none');
940                            }
941                        }
942                    }
943                }
944            }
945        });
946
947        $(document).on('change', 'input[name^="ays_questions"]', function (e) {
948            var quizContainer = $(e.target).parents('.ays-quiz-container');
949            if(typeof myOptions != 'undefined'){
950                var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
951                if(isRequiredQuestion === true){
952                    if($(e.target).attr('type') === 'radio' || $(e.target).attr('type') === 'checkbox'){
953                        if($(e.target).parents('div[data-question-id]').find('input[name^="ays_questions"]:checked').length != 0){
954                            if (!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
955                                $(e.target).parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled');
956                                $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled');
957                            }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
958                                $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled');
959                                $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled');
960                            }
961                        }else{
962                            if (!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
963                                $(e.target).parents('div[data-question-id]').find('input.ays_next').attr('disabled', true);
964                                $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', true);
965                            }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
966                                $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', true);
967                                $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', true);
968                            }
969                        }
970                    }
971                }
972            }
973
974            if($(e.target).parents('.step').hasClass('not_influence_to_score')){
975                if($(e.target).attr('type') === 'radio') {
976                    $(e.target).parents('.ays-quiz-answers').find('.checked_answer_div').removeClass('checked_answer_div');
977                    $(e.target).parents('.ays-field').addClass('checked_answer_div');
978                }
979                if($(e.target).attr('type') === 'checkbox') {
980                    if(!$(e.target).parents('.ays-field').hasClass('checked_answer_div')){
981                        $(e.target).parents('.ays-field').addClass('checked_answer_div');
982                    }else{
983                        $(e.target).parents('.ays-field').removeClass('checked_answer_div');
984                    }
985                } 
986                var checked_inputs = $(e.target).parents().eq(1).find('input:checked');
987                if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
988                    if (checked_inputs.attr('type') === 'radio') {
989                        checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click');                    
990                    }
991                }
992                if ($(e.target).parents().eq(4).hasClass('enable_correction')) {                    
993                    if (checked_inputs.attr('type') === "radio") {
994                        $(e.target).parents('div[data-question-id]').find('input[name^="ays_questions"]').attr('disabled', true);
995                        $(e.target).parents('div[data-question-id]').find('input[name^="ays_questions"]').off('change');
996                    } else if (checked_inputs.attr('type') === "checkbox") {
997                        $(e.target).attr('disabled', true);
998                        $(e.target).off('change');
999                    }
1000                }
1001                return false;
1002            }
1003            if ($(e.target).parents().eq(4).hasClass('enable_correction')) {
1004                var right_answer_sound = quizContainer.find('.ays_quiz_right_ans_sound').get(0);
1005                var wrong_answer_sound = quizContainer.find('.ays_quiz_wrong_ans_sound').get(0);
1006                var finishAfterWrongAnswer = (myOptions.finish_after_wrong_answer && myOptions.finish_after_wrong_answer == "on") ? true : false;
1007                var showOnlyWrongAnswer = (myOptions.show_only_wrong_answer && myOptions.show_only_wrong_answer == "on") ? true : false;
1008                var explanationTime = myOptions.explanation_time && myOptions.explanation_time != "" ? parseInt(myOptions.explanation_time) : 4;
1009                var showExplanationOn = (myOptions.show_questions_explanation && myOptions.show_questions_explanation != "") ? myOptions.show_questions_explanation : "on_results_page";
1010                var next_sibilings_count = quizContainer.find('.ays_question_count_per_page').val();
1011                var enableNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == 'on') ? true : false;
1012                var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
1013                var thankYouStep = quizContainer.find('div.step.ays_thank_you_fs');
1014                var infoFormLast = thankYouStep.prev().find('div.information_form');
1015                // Display all questions on one page
1016                myOptions.quiz_display_all_questions = ( myOptions.quiz_display_all_questions ) ? myOptions.quiz_display_all_questions : 'off';
1017                var quiz_display_all_questions = (myOptions.quiz_display_all_questions && myOptions.quiz_display_all_questions == "on") ? true : false;
1018
1019                var disableQuestions = false;
1020                if( parseInt( next_sibilings_count ) > 0 || quiz_display_all_questions == true ){
1021                    disableQuestions = true;
1022                }
1023
1024                if ($(e.target).parents().eq(1).find('input[name="ays_answer_correct[]"]').length !== 0) {
1025                    var checked_inputs = $(e.target).parents().eq(1).find('input:checked');
1026                    if (checked_inputs.attr('type') === "radio") {
1027                        checked_inputs.nextAll().addClass('answered');
1028                        checked_inputs.parent().addClass('checked_answer_div');
1029                        if (checked_inputs.prev().val() == 1){
1030                            checked_inputs.nextAll().addClass('correct')
1031                            checked_inputs.parent().addClass('correct_div');
1032
1033                            if( aysThisQuizBullets !== null ){
1034                                var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
1035                                var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
1036                                thisBullet.attr('disabled', 'disabled');
1037                                thisBullet.addClass('ays_quiz_correct_answer');
1038                                thisBullet.parent().addClass('ays_quiz_checked_answer_div');
1039                            }
1040                        }else{
1041                            checked_inputs.nextAll().addClass('wrong');
1042                            checked_inputs.parent().addClass('wrong_div');
1043
1044                            if( aysThisQuizBullets !== null ){
1045                                var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
1046                                var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
1047                                thisBullet.attr('disabled', 'disabled');
1048                                thisBullet.addClass('ays_quiz_wrong_answer');
1049                                thisBullet.parent().addClass('ays_quiz_checked_answer_div');
1050                            }
1051                        }
1052
1053                        if (checked_inputs.prev().val() == 1) {
1054                            $(e.target).parents('.ays-field').addClass('correct_div checked_answer_div');
1055                            $(e.target).next('label').addClass('correct answered');
1056
1057                            if(myOptions.answers_rw_texts && (myOptions.answers_rw_texts == 'on_passing' || myOptions.answers_rw_texts == 'on_both')){
1058                                if(! $(e.target).parents('.step').hasClass('not_influence_to_score')){
1059                                    $(e.target).parents().eq(3).find('.right_answer_text').slideDown(250);
1060                                }
1061                                explanationTimeout = setTimeout(function(){
1062                                    if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
1063                                        checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
1064                                        if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
1065                                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
1066                                            if ( existsEmtpyQuestions ) {
1067                                                if(infoFormLast.length == 0){
1068                                                    quizContainer.find('input.ays_finish').trigger('click');
1069                                                } else {
1070                                                    quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
1071                                                }
1072                                            }
1073                                        } else {
1074                                            checked_inputs.parents('div[data-question-id]').find('.ays_
1074next').trigger('click');
1075                                        }
1076                                    } else if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
1077                                        var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
1078                                        if ( existsEmtpyQuestions ) {
1079                                            if(infoFormLast.length == 0){
1080                                                quizContainer.find('input.ays_finish').trigger('click');
1081                                            } else {
1082                                                quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
1083                                            }
1084                                        }
1085                                    }
1086                                }, explanationTime * 1000);
1087                            }else{
1088                                explanationTimeout = setTimeout(function(){
1089                                    if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
1090                                        checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
1091                                        if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
1092                                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
1093                                            if ( existsEmtpyQuestions ) {
1094                                                if(infoFormLast.length == 0){
1095                                                    quizContainer.find('input.ays_finish').trigger('click');
1096                                                } else {
1097                                                    quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
1098                                                }
1099                                            }
1100                                        } else {
1101                                            checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click');
1102                                        }
1103                                    } else if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
1104                                        var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
1105                                        if ( existsEmtpyQuestions ) {
1106                                            if(infoFormLast.length == 0){
1107                                                quizContainer.find('input.ays_finish').trigger('click');
1108                                            } else {
1109                                                quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
1110                                            }
1111                                        }
1112                                    }
1113                                }, explanationTime * 1000);
1114                            }
1115                            if((right_answer_sound)){
1116                                resetPlaying([right_answer_sound, wrong_answer_sound]);
1117                                setTimeout(function(){
1118                                    right_answer_sound.play();
1119                                }, 10);
1120                            }
1121                        }
1122                        else {
1123                            if(showOnlyWrongAnswer === false){
1124                                $(e.target).parents('.ays-quiz-answers').find('input[name="ays_answer_correct[]"][value="1"]').parent().addClass('correct_div checked_answer_div');
1125                                $(e.target).parents('.ays-quiz-answers').find('input[name="ays_answer_correct[]"][value="1"]').nextAll().addClass('correct answered');
1126                                $(e.target).parents('.ays-field').addClass('wrong_div');
1127                            }
1128
1129                            if(myOptions.answers_rw_texts && (myOptions.answers_rw_texts == 'on_passing' || myOptions.answers_rw_texts == 'on_both')){
1130                                if(! $(e.target).parents('.step').hasClass('not_influence_to_score')){
1131                                    $(e.target).parents().eq(3).find('.wrong_answer_text').slideDown(250);
1132                                }
1133                                if(finishAfterWrongAnswer){
1134                                    checked_inputs.parents('div[data-question-id]').find('.ays_
1134next').attr('disabled', 'disabled');
1135                                    checked_inputs.parents('div[data-question-id]').find('.ays_early_finish').attr('disabled', 'disabled');
1136                                    checked_inputs.parents('div[data-question-id]').find('.ays_previous').attr('disabled', 'disabled');
1137                                    if( disableQuestions ){
1138                                        quizContainer.find('div[data-question-id]').css('pointer-events', 'none');
1139                                    }
1140                                }
1141                                explanationTimeout = setTimeout(function(){
1142                                    if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
1143                                        checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
1144                                        if(finishAfterWrongAnswer){
1145                                            goToLastPage(e);
1146                                        } else if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
1147                                                var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
1148                                                if ( existsEmtpyQuestions ) {
1149                                                    if(infoFormLast.length == 0){
1150                                                        quizContainer.find('input.ays_finish').trigger('click');
1151                                                    } else {
1152                                                        quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
1153                                                    }
1154                                                }
1155                                        } else{
1156                                            if ( isRequiredQuestion ) {
1157                                                var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
1158                                                if ( existsEmtpyQuestions ) {
1159                                                    checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click');
1160                                                }
1161                                            } else {
1162                                                checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click');
1163                                            }
1164                                        }
1165                                    }else{
1166                                        if(finishAfterWrongAnswer){
1167                                            goToLastPage(e);
1168                                        } 
1169                                        else if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
1170                                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
1171                                            if ( existsEmtpyQuestions ) {
1172                                                if(infoFormLast.length == 0){
1173                                                    quizContainer.find('input.ays_finish').trigger('click');
1174                                                } else {
1175                                                    quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
1176                                                }
1177                                            }
1178                                        }
1179                                    }
1180                                }, explanationTime * 1000);
1181                            }else{
1182                                if(finishAfterWrongAnswer){
1183                                    if( disableQuestions ){
1184                                        quizContainer.find('div[data-question-id]').css('pointer-events', 'n
1184one');
1185                                    }
1186                                }
1187
1188                                if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
1189                                    checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
1190                                    if(finishAfterWrongAnswer){
1191                                        goToLastPage(e);
1192                                    } else if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
1193                                        explanationTimeout = setTimeout(function(){
1194                                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
1195                                            if ( existsEmtpyQuestions ) {
1196                                                if(infoFormLast.length == 0){
1197                                                    quizContainer.find('input.ays_finish').trigger('click');
1198                                                } else {
1199                                                    quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
1200                                                }
1201                                            }
1202                                        }, explanationTime * 1000);
1203                                    } else{
1204                                        if ( isRequiredQuestion ) {
1205                                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
1206                                            if ( existsEmtpyQuestions ) {
1207                                                checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click');
1208                                            }
1209                                        } else {
1210                                            checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click');
1211                                        }
1212                                    }
1213                                }else{
1214                                    if(finishAfterWrongAnswer){
1215                                        goToLastPage(e);
1216                                    } 
1217                                    else if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
1218                                        explanationTimeout = setTimeout(function(){
1219                                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
1220                                            if ( existsEmtpyQuestions ) {
1221                                                if(infoFormLast.length == 0){
1222                                                    quizContainer.find('input.ays_finish').trigger('click');
1223                                                } else {
1224                                                    quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
1225                                                }
1226                                            }
1227                                        }, explanationTime * 1000);
1228                                    }
1229                                }
1230                            }
1231                            if((wrong_answer_sound)){
1232                                resetPlaying([right_answer_sound, wrong_answer_sound]);
1233                                setTimeout(function(){
1234                                    wrong_answer_sound.play();
1235                                }, 10);
1236                            }
1237                            if(finishAfterWrongAnswer){
1238                                if( aysThisQuizBullets !== null ){
1239                                    aysThisQuizBullets.baseElement.find('.ays_questions_nav_question').each(function(){
1240                                        var thisBullet = $(this);
1241                                        thisBullet.attr('disabled', 'disabled');
1242                                    });
1243                                }
1244                            }
1245                        }
1246
1247                        if(showExplanationOn == 'on_passing' || showExplanationOn == 'on_both'){
1248                            if(! $(e.target).parents('.step').hasClass('not_influence_to_score')){
1249                                $(e.target).parents().eq(3).find('.ays_questtion_explanation').slideDown(250);
1250                            }
1251                        }
1252                        $(e.target).parents('div[data-question-id]').find('input[name^="ays_questions"]').attr('disabled', true);
1253                        $(e.target).parents('div[data-question-id]').find('input[name^="ays_questions"]').off('change');
1254                        $(e.target).parents('div[data-question-id]').find('.ays-field').css({
1255                            'pointer-events': 'none'
1256                        });
1257
1258                    }else if(checked_inputs.attr('type') === "checkbox"){
1259                        checked_inputs = $(e.target);
1260                        if( $(e.target).parents().eq(1).find('input
1260:checked').length > 0 ){
1261                            if( aysThisQuizBullets !== null ){
1262                                var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
1263                                var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
1264                                thisBullet.parent().addClass('ays-quiz-questions-nav-item-answered');
1265                            }
1266                        }
1267
1268                        if (checked_inputs.length === 1) {
1269                            checked_inputs.parent().addClass('checked_answer_div');
1270                            if(checked_inputs.prev().val() == 1){
1271                                if((right_answer_sound)){
1272                                    resetPlaying([right_answer_sound, wrong_answer_sound]);
1273                                    setTimeout(function(){
1274                                        right_answer_sound.play();
1275                                    }, 10);
1276                                }
1277                                checked_inputs.parents('.ays-field').addClass('correct_div checked_answer_div');
1278                                checked_inputs.nextAll().addClass('correct answered');
1279                            }else{
1280                                if((wrong_answer_sound)){
1281                                    resetPlaying([right_answer_sound, wrong_answer_sound]);
1282                                    setTimeout(function(){
1283                                        wrong_answer_sound.play();
1284                                    }, 10);
1285                                }
1286                                if(finishAfterWrongAnswer){
1287                                    goToLastPage(e);
1288                                    if( disableQuestions ){
1289                                        quizContainer.find('div[data-question-id]').css('pointer-events', 'none');
1290                                    }
1291                                    if( aysThisQuizBullets !== null ){
1292                                        aysThisQuizBullets.baseElement.find('.ays_questions_nav_question').each(function(){
1293                                            var thisBullet = $(this);
1294                                            thisBullet.attr('disabled', 'disabled');
1295                                        });
1296                                    }
1297                                }
1298                                checked_inputs.parent().addClass('wrong_div');
1299                                checked_inputs.nextAll().addClass('wrong answered');
1300                            }
1301                        }else{
1302                            for (var i = 0; i < checked_inputs.length; i++) {
1303                                if(checked_inputs.eq(i).prev().val() == 1){
1304                                    if((right_answer_sound)){
1305                                        resetPlaying([right_answer_sound, wrong_answer_sound]);
1306                                        setTimeout(function(){
1307                                            right_answer_sound.play();
1308                                        }, 10);
1309                                    }
1310                                    checked_inputs.eq(i).nextAll().addClass('correct answered');
1311                                    checked_inputs.eq(i).parent().addClass('correct_div');
1312                                    checked_inputs.eq(i).parent().addClass('checked_answer_div');
1313                                }else{
1314                                    if((wrong_answer_sound)){
1315                                        resetPlaying([right_answer_sound, wrong_answer_sound]);
1316                                        setTimeout(function(){
1317                                            wrong_answer_sound.play();
1318                                        }, 10);
1319                                    }
1320                                    if(finishAfterWrongAnswer){
1321                                        goToLastPage(e);
1322                                        if( disableQuestions ){
1323                                            quizContainer.find('div[data-question-id]').css('pointer-events', 'n
1323one');
1324                                        }
1325                                    }
1326                                    checked_inputs.eq(i).parent().addClass('checked_answer_div');
1327                                    checked_inputs.eq(i).nextAll().addClass('wrong answered');
1328                                    checked_inputs.eq(i).parent().addClass('wrong_div');
1329                                }
1330                            }
1331                            if(checked_inputs.eq(i).prev().val() == 1){
1332                                checked_inputs.eq(i).next().addClass('correct answered');
1333                                if((right_answer_sound)){
1334                                    resetPlaying([right_answer_sound, wrong_answer_sound]);
1335                                    setTimeout(function(){
1336                                        right_answer_sound.play();
1337                                    }, 10);
1338                                }
1339                            }else{
1340                                checked_inputs.eq(i).next().addClass('wrong answered');
1341                                if((wrong_answer_sound)){
1342                                    resetPlaying([right_answer_sound, wrong_answer_sound]);
1343                                    setTimeout(function(){
1344                                        wrong_answer_sound.play();
1345                                    }, 10);
1346                                }
1347                                if(finishAfterWrongAnswer){
1348                                    if( aysThisQuizBullets !== null ){
1349                                        aysThisQuizBullets.baseElement.find('.ays_questions_nav_question').each(function(){
1350                                            var thisBullet = $(this);
1351                                            thisBullet.attr('disabled', 'disabled');
1352                                        });
1353                                    }
1354                                }
1355                            }
1356                        }
1357
1358                        $(e.target).attr('disabled', true);
1359                        $(e.target).off('change');
1360                    }
1361                }
1362            }else{                
1363                if($(e.target).attr('type') === 'radio') {
1364                    $(e.target).parents('.ays-quiz-answers').find('.checked_answer_div').removeClass('checked_answer_div');
1365                    $(e.target).parents('.ays-field').addClass('checked_answer_div');
1366                }
1367                if($(e.target).attr('type') === 'checkbox') {
1368                    if(!$(e.target).parents('.ays-field').hasClass('checked_answer_div')){
1369                        $(e.target).parents('.ays-field').addClass('checked_answer_div');
1370                    }else{
1371                        $(e.target).parents('.ays-field').removeClass('checked_answer_div');
1372                    }
1373                } 
1374                var checked_inputs = $(e.target).parents().eq(1).find('input:checked');
1375                if( checked_inputs.length > 0 ){
1376                    if( aysThisQuizBullets !== null ){
1377                        var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
1378                        var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
1379                        thisBullet.parent().addClass('ays-quiz-questions-nav-item-answered');
1380                    }
1381                }else{
1382                    if( aysThisQuizBullets !== null ){
1383                        var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
1384                        var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
1385                        thisBullet.parent().removeClass('ays-quiz-questions-nav-item-answered');
1386                    }
1387                }
1388
1389                if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
1390                    checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
1391                    if (checked_inputs.attr('type') === 'radio') {
1392                        checked_inputs.parents('div[data-question-id]').find('input.ays_next').trigger('click');
1393                    }
1394                }
1395            }
1396        });
1397
1398        $(document).on('change', 'textarea[name^="ays_questions"], input[type="text"][name^="ays_questions"], input[type="number"][name^="ays_questions"], input[type="date"][name^="ays_questions"]', function (e) {
1399            if( $(e.target).val().length > 0 ){
1400                if( aysThisQuizBullets !== null ){
1401                    var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
1402                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
1403                    thisBullet.parent().addClass('ays-quiz-questions-nav-item-answered');
1404                }
1405            }else{
1406                if( aysThisQuizBullets !== null ){
1407                    var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
1408                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
1409                    thisBullet.parent().removeClass('ays-quiz-questions-nav-item-answered');
1410                }
1411            }
1412        });
1413
1414        $(document).on('input', 'textarea[name^="ays_questions"], input[name^="ays_questions"]', function (e) {
1415
1416            if( $(e.target).val().length > 0 ){
1417                if( aysThisQuizBullets !== null ){
1418                    var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
1419                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
1420                    thisBullet.parent().addClass('ays-quiz-questions-nav-item-answered');
1421                }
1422            }else{
1423                if( aysThisQuizBullets !== null ){
1424                    var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
1425                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
1426                    thisBullet.parent().removeClass('ays-quiz-questions-nav-item-answered');
1427                }
1428            }
1429
1430            if(typeof myOptions != 'undefined'){
1431                var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
1432                if(isRequiredQuestion === true){
1433                    if($(e.target).attr('type') === 'text' ||
1434                       $(e.target).attr('type') === 'number' ||
1435                       $(e.target).attr('type') === 'date'){
1436                        if($(e.target).val() != ''){
1437                            if (!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
1438                                $(e.target).parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled');
1439                                $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled');
1440                            }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
1441                                $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled');
1442                                $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled');
1443                            }
1444                        }else{
1445                            if (!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
1446                                $(e.target).parents('div[data-question-id]').find('input.ays_next').attr('disabled', true);
1447                                $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', true);
1448                            }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
1449                                $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', true);
1450                                $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', true);
1451                            }
1452                        }
1453                    }
1454                }
1455            }
1456        });
1457
1458        $(document).on('input', '.information_form input[name="ays_user_phone"]', function(){
1459            if ($(this).attr('type') !== 'hidden') {
1460                $(this).removeClass('ays_red_border');
1461                $(this).removeClass('ays_green_border');
1462                if($(this).val() != ''){
1463                    if (!validatePhoneNumber($(this).get(0))) {
1464                        $(this).addClass('ays_red_border');
1465                    }else{
1466                        $(this).addClass('ays_green_border');
1467                    }
1468                }
1469            }
1470        });
1471        
1472        $(document).on('input', 'input.ays_quiz_password', function(e){
1473            var $this = $(this);
1474            var startButton = $this.parents('.ays-quiz-container').find('input.start_button');
1475            if($this.val() != ''){
1476                startButton.removeAttr('disabled');
1477            }else{
1478                startButton.attr('disabled', 'disabled');
1479            }
1480        });
1481
1482        $(document).on('click', '.ays-quiz-password-toggle', function(e){
1483            var $this  = $(this);
1484
1485            var parent = $this.parents('.ays-quiz-password-toggle-visibility-box');
1486            var passwordInput = parent.find('.ays_quiz_password');
1487
1488            var visibilityOn  = parent.find('.ays-quiz-password-toggle-visibility');
1489            var visibilityOff = parent.find('.ays-quiz-password-toggle-visibility-off');
1490
1491            if( $this.hasClass('ays-quiz-password-toggle-visibility-off') ) {
1492                passwordInput.attr('type', 'text');
1493
1494                if ( visibilityOn.hasClass('ays_display_none') ) {
1495                    visibilityOn.removeClass('ays_display_none');
1496                }
1497
1498                if ( ! visibilityOff.hasClass('ays_display_none') ) {
1499                    visibilityOff.addClass('ays_display_none');
1500                }
1501
1502            } else if( $this.hasClass('ays-quiz-password-toggle-visibility') ) {
1503                passwordInput.attr('type', 'password');
1504
1505                if ( ! visibilityOn.hasClass('ays_display_none') ) {
1506                    visibilityOn.addClass('ays_display_none');
1507                }
1508
1509                if ( visibilityOff.hasClass('ays_display_none') ) {
1510                    visibilityOff.removeClass('ays_display_none');
1511                }
1512            }
1513        });
1514
1515        setTimeout(function(){
1516            $(document).find('input.ays_quiz_password').val('');
1517        }, 500);
1518
1519        $(document).on('input', '.information_form input[name="ays_user_email"], .information_form input[type="email"]', function(){
1520            if ($(this).attr('type') !== 'hidden') {
1521                $(this).removeClass('ays_red_border');
1522                $(this).removeClass('ays_green_border');
1523                if($(this).val() != ''){
1524                    if (!(emailValivatePattern.test($(this).val()))) {
1525                        $(this).addClass('ays_red_border');
1526                    }else{
1527                        $(this).addClass('ays_green_border');
1528                    }
1529                }
1530            }
1531        });
1532
1533        $(document).find('.ays-text-field .ays-text-input').each(function(ev){
1534            $(this).on('keydown', function(e){
1535                myOptions.enable_enter_key = !( myOptions.enable_enter_key ) ? "on" : myOptions.enable_enter_key;
1536                var enableEnterKey = (myOptions.enable_enter_key && myOptions.enable_enter_key == "on") ? true : false;
1537                var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
1538                if(enableEnterKey){
1539                    if (e.keyCode === 13 && !e.shiftKey) {
1540                        if(animating){
1541                            return false;
1542                        }
1543                        if(isRequiredQuestion === true){
1544                            if($(this).val() == ''){
1545                                return false;
1546                            }
1547                        }
1548                        if($(this).parents('.step').find('input.ays_finish.action-button').length > 0){
1549                            $(this).parents('.step').find('input.ays_finish.action-button').trigger('click');
1550                        }else{
1551                            $(this).parents('.step').find('input.ays_next.action-button').trigger('click');
1552                        }
1553                        $(this).trigger('blur');
1554                        return false;
1555                    }
1556                }
1557            });
1558        });
1559
1560        $(document).find('.ays_next').on('click', function(e){
1561            e.preventDefault();
1562            var quizId = $(this).parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
1563
1564            if(checkQuizPassword(e, myOptions, true) === false){
1565                return false;
1566            }
1567
1568            if ( typeof window.aysSeeResultConfirmBox[ quizId ] != 'undefined' && window.aysSeeResultConfirmBox[ quizId ] ) {
1569                window.aysSeeResultConfirmBox[ quizId ] = false;
1570                return false;
1571            }
1572
1573            if(typeof explanationTimeout != 'undefined'){
1574                clearTimeout(explanationTimeout);
1575            }
1576
1577            ays_quiz_container = $(this).parents(".ays-quiz-container");
1578            if (!($(this).hasClass('start_button'))) {
1579                if ($(this).parents('.step').find('input[required]').length !== 0) {
1580                    var empty_inputs = 0;
1581                    var required_inputs = $(this).parents('.step').find('input[required]');
1582                    $(this).parents('.step').find('.ays_red_border').removeClass('ays_red_border');
1583                    $(this).parents('.step').find('.ays_green_border').removeClass('ays_green_border');
1584                    for (var i = 0; i < required_inputs.length; i++) {
1585                        switch(required_inputs.eq(i).attr('type')){
1586                            case "checkbox": {
1587                                if(required_inputs.eq(i).prop('checked') === false){
1588                                    required_inputs.eq(i).addClass('ays_red_border');
1589                                    required_inputs.eq(i).addClass('shake');
1590                                    empty_inputs++;
1591                                }else{
1592                                    required_inputs.eq(i).addClass('ays_green_border');
1593                                }
1594                                break;
1595                            }
1596                            case "email": {
1597                                if (!(emailValivatePattern.test(required_inputs.eq(i).val()))) {
1598                                    required_inputs.eq(i).addClass('ays_red_border');
1599                                    required_inputs.eq(i).addClass('shake');
1600                                    empty_inputs++;
1601                                }else{
1602                                    required_inputs.eq(i).addClass('ays_green_border');
1603                                }
1604                                break;
1605                            }
1606                            case "tel": {
1607                                if (!validatePhoneNumber(required_inputs.eq(i).get(0))) {
1608                                    required_inputs.eq(i).addClass('ays_red_border');
1609                                    required_inputs.eq(i).addClass('shake');
1610                                    empty_inputs++;
1611                                }else{
1612                                    required_inputs.eq(i).addClass('ays_green_border');
1613                                }
1614                                break;
1615                            }
1616                            default:{
1617                                if (required_inputs.eq(i).val().trim() === '' &&
1618                                    required_inputs.eq(i).attr('type') !== 'hidden') {
1619                                    required_inputs.eq(i).addClass('ays_red_border');
1620                                    required_inputs.eq(i).addClass('shake');
1621                                    empty_inputs++;
1622                                }else{
1623                                    required_inputs.eq(i).addClass('ays_green_border');
1624                                }
1625                                break;
1626                            }
1627                        }
1628                    }
1629                    var empty_inputs2 = 0;
1630                    var phoneInput = $(this).parents('.step').find('input[name="ays_user_phone"]');
1631                    var emailInput = $(this).parents('.step').find('input[name="ays_user_email"]');
1632                    var selectAttr = $(this).parents('.step').find('select.ays_quiz_form_input[required]');
1633                    if(phoneInput.val() != ''){
1634                        phoneInput.removeClass('ays_red_border');
1635                        phoneInput.removeClass('ays_green_border');
1636                        if (!validatePhoneNumber(phoneInput.get(0))) {
1637                            if (phoneInput.attr('type') !== 'hidden') {
1638                                phoneInput.addClass('ays_red_border');
1639                                phoneInput.addClass('shake');
1640                                empty_inputs2++;
1641                            }
1642                        }else{
1643                            phoneInput.addClass('ays_green_border');
1644                        }
1645                    }
1646                    if(emailInput.val() != ''){
1647                        emailInput.removeClass('ays_red_border');
1648                        emailInput.removeClass('ays_green_border');
1649                        if (!(emailValivatePattern.test(emailInput.val()))) {
1650                            if (emailInput.attr('type') !== 'hidden') {
1651                                emailInput.addClass('ays_red_border');
1652                                emailInput.addClass('shake');
1653                                empty_inputs++;
1654                            }
1655                        }else{
1656                            emailInput.addClass('ays_green_border');
1657                        }
1658                    }
1659
1660                    for (var i = 0; i < selectAttr.length; i++) {
1661                        if(selectAttr.eq(i).val() == ''){
1662                            selectAttr.eq(i).removeClass('ays_red_border');
1663                            selectAttr.eq(i).removeClass('ays_green_border');
1664
1665                            selectAttr.eq(i).addClass('ays_red_border');
1666                            selectAttr.eq(i).addClass('shake');
1667                            empty_inputs++;
1668                        }else{
1669                            selectAttr.eq(i).removeClass('ays_red_border');
1670                        }
1671                    }
1672                    var errorFields = $(this).parents('.step').find('.ays_red_border');
1673                    if (empty_inputs2 !== 0 || empty_inputs !== 0) {
1674                        setTimeout(function(){
1675                            errorFields.each(function(){
1676                                $(this).removeClass('shake');
1677                            });
1678                        }, 500);
1679                        setTimeout(function(){
1680                            required_inputs.each(function(){
1681                                $(this).removeClass('shake');
1682                            });
1683                        }, 500);
1684                        return false;
1685                    }else{
1686                        $(this).addClass('ays_start_allow');
1687                    }
1688                }else{
1689                    if ($(this).parents('.step').find('.information_form').length !== 0 ){
1690                        var empty_inputs = 0;
1691                        var phoneInput = $(this).parents('.step').find('input[name="ays_user_phone"]');
1692                        var emailInput = $(this).parents('.step').find('input[name="ays_user_email"]');
1693                        var emailInputs = $(this).parents('.step').find('input[type="email"]');
1694                        if(phoneInput.val() != ''){
1695                            phoneInput.removeClass('ays_red_border');
1696                            phoneInput.removeClass('ays_green_border');
1697                            if (!validatePhoneNumber(phoneInput.get(0))) {
1698                                if (phoneInput.attr('type') !== 'hidden') {
1699                                    phoneInput.addClass('ays_red_border');
1700                                    phoneInput.addClass('shake');
1701                                    empty_inputs++;
1702                                }
1703                            }else{
1704                                phoneInput.addClass('ays_green_border');
1705                            }
1706                        }
1707                        if(emailInput.val() != ''){
1708                            emailInput.removeClass('ays_red_border');
1709                            emailInput.removeClass('ays_green_border');
1710                            if (!(emailValivatePattern.test(emailInput.val()))) {
1711                                if (emailInput.attr('type') !== 'hidden') {
1712                                    emailInput.addClass('ays_red_border');
1713                                    emailInput.addClass('shake');
1714                                    empty_inputs++;
1715                                }
1716                            }else{
1717                                emailInput.addClass('ays_green_border');
1718                            }
1719                        }
1720                        emailInputs.each(function(){
1721                            var thisEmailInput = $(this);
1722                            if(thisEmailInput.val() != ''){
1723                                thisEmailInput.removeClass('ays_red_border');
1724                                thisEmailInput.removeClass('ays_green_border');
1725                                if (!(emailValivatePattern.test(thisEmailInput.val()))) {
1726                                    thisEmailInput.addClass('ays_red_border');
1727                                    thisEmailInput.addClass('shake');
1728                                    empty_inputs++;
1729                                }else{
1730                                    thisEmailInput.addClass('ays_green_border');
1731                                }
1732                            }
1733                        });
1734                        var errorFields = $(this).parents('.step').find('.ays_red_border');
1735                        if (empty_inputs !== 0) {
1736                            setTimeout(function(){
1737                                errorFields.each(function(){
1738                                    $(this).removeClass('shake');
1739                                });
1740                            }, 500);
1741                            return false;
1742                        }
1743                        $(this).addClass('ays_start_allow');
1744                    }
1745                }
1746            }
1747            
1748            if (animating) return false;
1749            animating = true;
1750            current_fs = $(this).parents('.step');
1751            next_fs = $(this).parents('.step').next();
1752
1753
1754            if( current_fs.find('.information_form').length != 0 && !($(this).hasClass('ays_finish'))){
1755                $(this).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').slideDown(500);
1756            }
1757
1758            if( next_fs.find('.information_form').length != 0 ){
1759                $(this).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').slideUp(500);
1760            }
1761
1762            var questions_count = $(this).parents('form').find('div[data-question-id]').length;
1763            var curent_number = $(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]')) + 1;
1764            var next_sibilings_count = $(this).parents('form').find('.ays_question_count_per_page').val();
1765
1766            // Display all questions on one page
1767            myOptions.quiz_display_all_questions = ( myOptions.quiz_display_all_questions ) ? myOptions.quiz_display_all_questions : 'off';
1768            var quiz_display_all_questions = (myOptions.quiz_display_all_questions && myOptions.quiz_display_all_questions == "on") ? true : false;
1769
1770            // Enable finish button
1771            myOptions.enable_early_finish = ( myOptions.enable_early_finish ) ? myOptions.enable_early_finish : 'off';
1772            var enable_early_finish = (myOptions.enable_early_finish && myOptions.enable_early_finish == "on") ? true : false;
1773
1774            var enableNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == 'on') ? true : false;
1775
1776            if ( quiz_display_all_questions ) {
1777                next_sibilings_count = questions_count;
1778            }
1779
1780            if(parseInt(next_sibilings_count)>0 && ($(this).parents('.step').attr('data-question-id') || $(this).parents('.step').next().attr('data-question-id'))){
1781                if(parseInt(next_sibilings_count) >= questions_count){
1782                    next_sibilings_count = questions_count;
1783                }
1784
1785                var current_fs_index = $(this).parents('form').find('.step').index($(this).parents('.step'));
1786                if($(this).parents('.step').attr('data-question-id')){
1787                    current_fs = $(this).parents('form').find('.step').slice(current_fs_index-parseInt(next_sibilings_count),current_fs_index+1);
1788                }else{
1789                    current_fs = $(this).parents('.step');
1790                }
1791                if(questions_count === curent_number){
1792                    if(current_fs.hasClass('.information_form').length !== 0){
1793                        current_fs.find('.ays_next').eq(current_fs.find('.ays_next').length-1).addClass('ays_timer_end');
1794                        current_fs.parents('.ays-quiz-container').find('.ays-quiz-timer').slideUp(500);
1795                    }
1796                }
1797                
1798
1799                if(curent_number != questions_count){
1800                    if(($(this).hasClass('ays_finish')) == false){
1801                        if (!($(this).hasClass('start_button'))) {
1802                            var count_per_page = Math.floor(questions_count/parseInt(next_sibilings_count));
1803                            var nextCountQuestionsPerPage = questions_count-curent_number;
1804                            var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width();
1805                            var final_width = ((curent_number+parseInt(next_sibilings_count)) / questions_count * 100) + "%";
1806                            if(nextCountQuestionsPerPage < parseInt(next_sibilings_count)){
1807                                final_width = ((curent_number+nextCountQuestionsPerPage) / questions_count * 100) + "%";
1808                            }
1809                            if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
1810                                if(nextCountQuestionsPerPage < parseInt(next_sibilings_count)){
1811                                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+parseInt(nextCountQuestionsPerPage)));
1812                                }else{
1813                                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+parseInt(next_sibilings_count)));
1814                                }
1815                            }else{
1816                                $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width));
1817                            }
1818                            $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
1819                        }
1820                    }
1821                }else{
1822                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut');
1823                    setTimeout(function () {
1824                        $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none');
1825                    },300)
1826                }
1827                var next_siblings = $(this).parents('.step').nextAll('.step').slice(0,parseInt(next_sibilings_count));
1828
1829                if($(this).parents('form').find('div[data-question-id]').index($(this).parents('.step'))+1 !== $(this).parents('form').find('div[data-question-id]').length) {
1830                    for (var z = 0; z < next_siblings.length; z++) {
1831                        if (next_siblings.eq(z).attr('data-question-id') === undefined) {
1832                            next_siblings.splice(z);
1833                        }
1834                    }
1835                }else{
1836                    if(next_siblings.length !== 1) {
1837                        next_siblings.splice(next_siblings.length - 1);
1838                    }
1839                }
1840
1841                if ($(this).parents('form').hasClass('enable_correction')) {
1842                    next_siblings.find('input[name^="ays_questions"]').each(function(){
1843                        if ($(this).parents('.ays-quiz-answers').find('.correct').length === 0 &&
1844                            $(this).parents('.ays-quiz-answers').find('.wrong').length === 0 &&
1845                            $(this).parents('.ays-quiz-answers').find('.ays-answered-text-input').length === 0) {
1846                            $(this).attr('disabled', false);
1847                        }
1848                    });
1849                }
1850
1851                for(var i=0 ;i<next_siblings.length-1;i++){
1852                    var nextQuestionType = next_siblings.eq(i).find('input[name^="ays_questions"]').attr('type');
1853                    var buttonsDiv = next_siblings.eq(i).find('.ays_buttons_div');
1854                    next_siblings.eq(i).find('.ays_previous').remove();
1855                    if(i === next_siblings.length-1 && next_siblings.eq(i).find('textarea[name^="ays_questions"]').attr('type')==='text'){
1856                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1857                        continue;
1858                    }
1859                    if(i === next_siblings.length-1 && nextQuestionType === 'checkbox'){
1860                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1861                        continue;
1862                    }
1863                    if(i === next_siblings.length-1 && nextQuestionType === 'number'){
1864                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1865                        continue;
1866                    }
1867                    if(i === next_siblings.length-1 && nextQuestionType === 'text'){
1868                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1869                        continue;
1870                    }
1871                    if(i === next_siblings.length-1 && nextQuestionType === 'date'){
1872                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1873                        continue;
1874                    }
1875                    next_siblings.eq(i).find('.ays_next').remove();
1876                    next_siblings.eq(i).find('.ays_early_finish').remove();
1877                }
1878
1879                if ( quiz_display_all_questions ) {
1880                    next_siblings.find('.ays_previous').remove();
1881                }
1882
1883                if(current_fs.hasClass('ays-abs-fs')){
1884                    current_fs = $(this).parents('.step');
1885                    next_fs = $(this).parents('.step').next();
1886                    current_fs.removeClass('active-step');
1887                    var counterClass = "";
1888                    switch(ays_quiz_container.data('questEffect')){
1889                        case "shake":
1890                            counterClass = ays_quiz_container.data('questEffect');
1891                        break;
1892                        case "fade":
1893                            counterClass = "fadeIn";
1894                        break;
1895                        case "none":
1896                            counterClass = "";
1897                        break;
1898                        default:
1899                            counterClass = ays_quiz_container.data('questEffect');
1900                        break;
1901                    }
1902                    next_fs.find('.ays-question-counter').addClass(counterClass);
1903                }
1904
1905                var nextQuestionType = next_siblings.eq(next_siblings.length-1).find('input[name^="ays_questions"]').attr('type');
1906                var buttonsDiv = next_siblings.eq(next_siblings.length-1).find('.ays_buttons_div');
1907                var enableArrows = $(document).find(".ays-questions-container .ays_qm_enable_arrows").val();
1908                if(myOptions.enable_arrows){
1909                    enableArrows = myOptions.enable_arrows == 'on' ? true : false;
1910                }else{
1911                    enableArrows = parseInt(enableArrows) == 1 ? true : false;
1912                }
1913
1914                if ( ! enable_early_finish ) {
1915                    buttonsDiv.find('i.ays_early_finish').addClass('ays_display_none');
1916                    buttonsDiv.find('input.ays_early_finish').addClass('ays_display_none');
1917                }
1918                
1919                var nextArrowIsDisabled = buttonsDiv.find('.ays_next_arrow').hasClass('ays_display_none');
1920                var nextButtonIsDisabled = buttonsDiv.find('.ays_next').hasClass('ays_display_none');
1921
1922                if(next_siblings.eq(next_siblings.length-1).find('textarea[name^="ays_questions"]').attr('type')==='text' && nextArrowIsDisabled && nextButtonIsDisabled){
1923                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1924                }
1925                if(next_siblings.eq(next_siblings.length-1).find('textarea[name^="ays_questions"]').attr('type') === 'text' && enableArrows){
1926                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
1927                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
1928                }
1929
1930
1931                if(nextQuestionType === 'checkbox' && nextArrowIsDisabled && nextButtonIsDisabled){
1932                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1933                }
1934                if(nextQuestionType === 'checkbox' && enableArrows){
1935                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
1936                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
1937                }
1938                if(nextQuestionType === 'number' && nextArrowIsDisabled && nextButtonIsDisabled){
1939                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1940                }
1941                if(nextQuestionType === 'number' && enableArrows){
1942                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
1943                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
1944                }
1945                if(nextQuestionType === 'text' && nextArrowIsDisabled && nextButtonIsDisabled){
1946                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1947                }
1948                if(nextQuestionType === 'text' && enableArrows){
1949                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
1950                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
1951                }
1952                if(nextQuestionType === 'date' && nextArrowIsDisabled && nextButtonIsDisabled){
1953                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1954                }
1955                if(nextQuestionType === 'date' && enableArrows){
1956                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
1957                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
1958                }
1959                
1960                var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
1961
1962                if(isRequiredQuestion === true){
1963                    if(next_siblings.find('.information_form').length === 0){
1964                        var existsEmtpyQuestions = ays_quiz_is_question_required( current_fs );
1965
1966                        if( ! next_siblings.hasClass('ays-filled-required-qestions') ){
1967                            if(enableArrows){
1968                                buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
1969                            }else{
1970                                buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
1971                            }
1972                        }
1973
1974                        if ( next_siblings.eq( next_siblings.length - 1 ).hasClass('ays-custom-step') ) {
1975                            var customQuestionStep = next_siblings.eq( next_siblings.length - 1 );
1976                            if(enableArrows){
1977                                customQuestionStep.find('i.ays_next_arrow').removeAttr('disabled');
1978                                buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
1979                            }else{
1980                                customQuestionStep.find('input.ays_next').removeAttr('disabled');
1981                                buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1982                            }
1983                        }
1984
1985                        if( existsEmtpyQuestions === false ){
1986                            return false;
1987                        }else{
1988                            current_fs.addClass('ays-filled-required-qestions');
1989                        }
1990                    } else if ( next_siblings.find('.information_form').length > 0 ) {
1991                        if ( !($(this).hasClass('start_button')) && quiz_display_all_questions && !enableNextButton ) {
1992                            var quizContainer = $(e.target).parents('.ays-quiz-container');
1993                            var existsEmtpyQuestions = ays_quiz_is_question_required( quizContainer.find('div[data-question-id]') );
1994                            
1995                            if( ! next_siblings.hasClass('ays-filled-required-qestions') ){
1996                                if(enableArrows){
1997                                    buttonsDiv.find('i.ays_next_arrow.ays_finish').prop('disabled', false);
1998                                }else{
1999                                    buttonsDiv.find('input.ays_next.ays_finish').prop('disabled', false);
2000                                }
2001                            }
2002
2003                            if( existsEmtpyQuestions === false ){
2004                                return false;
2005                            }else{
2006                                current_fs.addClass('ays-filled-required-qestions');
2007                            }
2008                        }
2009                    }
2010                }
2011
2012                if (!($(this).hasClass('start_button'))) {
2013                    var minSelHasError = 0;
2014                    var minSelQuestions = next_siblings;
2015                   // if(($(this).hasClass('ays_finish')) == false){
2016                   //     minSelQuestions = next_siblings;
2017                   // }else{
2018                        minSelQuestions = current_fs;
2019                   // }
2020
2021                    for( var k = 0; k < minSelQuestions.length; k++ ){
2022                        if( $( minSelQuestions[k] ).find('.enable_min_selection_number').length > 0 ){
2023                            var checkedMinSelCount = aysCheckMinimumCountCheckbox( $( minSelQuestions[k] ), myQuizOptions );
2024                            if( ays_quiz_is_question_min_count( $( minSelQuestions[k] ), !checkedMinSelCount ) === true ){
2025                                if( checkedMinSelCount == true ){
2026                                    if(enableArrows){
2027                                        buttonsDiv.find('i.ays_next_arrow').removeAttr('disabled');
2028                                        buttonsDiv.find('i.ays_next_arrow').prop('disabled', false);
2029                                    }else{
2030                                        buttonsDiv.find('input.ays_next').removeAttr('disabled');
2031                                        buttonsDiv.find('input.ays_next').prop('disabled', false);
2032                                    }
2033                                }else{
2034                                    if(enableArrows){
2035                                        buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
2036                                        buttonsDiv.find('i.ays_next_arrow').prop('disabled', true);
2037                                        buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2038                                    }else{
2039                                        buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
2040                                        buttonsDiv.find('input.ays_next').prop('disabled', true);
2041                                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2042                                    }
2043                                    minSelHasError++;
2044                                }
2045                            }else{
2046                                if(enableArrows){
2047                                    buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
2048                                    buttonsDiv.find('i.ays_next_arrow').prop('disabled', true);
2049                                    buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2050                                }else{
2051                                    buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
2052                                    buttonsDiv.find('input.ays_next').prop('disabled', true);
2053                                    buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2054                                }
2055                                minSelHasError++;
2056                            }
2057                        }
2058                    }
2059
2060                    if( minSelHasError > 0 ){
2061                        return false;
2062                    }
2063                }
2064
2065                ays_quiz_container.find('.active-step').removeClass('active-step');
2066                next_siblings.eq(0).addClass('active-step');
2067                aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_siblings);
2068
2069                next_siblings.eq(0).find('.ays-text-input').trigger( "focus" );
2070
2071                next_siblings.eq(0).find('.ays-text-input').trigger( "focus" );
2072                if ( ! next_siblings.eq(0).find('.ays-text-input').is(":focus") ) {
2073                    setTimeout(function(e){
2074                        next_siblings.eq(0).find('.ays-text-input').trigger( "focus" );
2075                    },1001);
2076                }
2077                setTimeout(function(){
2078                    if(next_siblings.find('.ays-text-field').length > 0){
2079                        if(next_siblings.find('.ays-text-field').width() < 250){
2080                            next_siblings.find('.ays-text-field').css({
2081                                'flex-wrap': 'wrap',
2082                                'justify-content': 'center',
2083                                'padding': '5px'
2084                            });
2085                            next_siblings.find('.ays-text-field').find('input.ays-text-input').css('margin-bottom', '5px');
2086                        }
2087                    }
2088                },2000);
2089            }else{
2090                current_fs = $(this).parents('.step');
2091                next_fs = $(this).parents('.step').next();
2092
2093                if( aysThisQuizBullets !== null ){
2094                    var thisQuestionID = next_fs.data('questionId');
2095                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]').parent();
2096                    aysThisQuizBullets._navPage(thisBullet.index());
2097                }
2098
2099                var questions_count = $(this).parents('form').find('div[data-question-id]').length;
2100                var curent_number = $(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]'))+1;
2101                if(questions_count === curent_number){
2102                    if(current_fs.hasClass('.information_form').length !== 0){
2103                        current_fs.find('.ays_next').addClass('ays_timer_end');
2104                        current_fs.parents('.ays-quiz-container').find('.ays-quiz-timer').slideUp(500);
2105                    }
2106                }
2107                if(curent_number != questions_count){
2108                    if(($(this).hasClass('ays_finish')) == false){
2109                        if (!($(this).hasClass('start_button'))) {
2110                            var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width();
2111                            var final_width = ((curent_number+1) / questions_count * 100) + "%";
2112                            if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
2113                                $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+1));
2114                            }else{
2115                                $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width));
2116                            }
2117                            $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
2118                        }
2119                    }
2120                }else{
2121                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut');
2122                    setTimeout(function () {
2123                        $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none');
2124                    },300)
2125                }
2126                if (current_fs.hasClass('ays-abs-fs')) {
2127                    current_fs = $(this).parents('.step');
2128                    next_fs = $(this).parents('.step').next();
2129                    var counterClass = "";
2130                    switch(ays_quiz_container.data('questEffect')){
2131                        case "shake":
2132                            counterClass = ays_quiz_container.data('questEffect');
2133                        break;
2134                        case "fade":
2135                            counterClass = "fadeIn";
2136                        break;
2137                        case "none":
2138                            counterClass = "";
2139                        break;
2140                        default:
2141                            counterClass = ays_quiz_container.data('questEffect');
2142                        break;
2143                    }
2144                    next_fs.find('.ays-question-counter').addClass(counterClass);
2145                }
2146                current_fs.removeClass('active-step');
2147                next_fs.addClass('active-step');
2148                var nextQuestionType = next_fs.find('input[name^="ays_questions"]').attr('type');
2149                var buttonsDiv = next_fs.find('.ays_buttons_div');
2150                var enableArrows = $(document).find(".ays-questions-container .ays_qm_enable_arrows").val();
2151
2152                if(myOptions.enable_arrows){
2153                    enableArrows = myOptions.enable_arrows == 'on' ? true : false;
2154                }else{
2155                    enableArrows = parseInt(enableArrows) == 1 ? true : false;
2156                }
2157                var nextArrowIsDisabled = buttonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none');
2158                var nextButtonIsDisabled = buttonsDiv.find('input.ays_next').hasClass('ays_display_none');
2159
2160                if(next_fs.find('textarea[name^="ays_questions"]').attr('type')==='text' && nextArrowIsDisabled && nextButtonIsDisabled){
2161                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2162                }
2163                if(next_fs.find('textarea[name^="ays_questions"]').attr('type')==='text' && enableArrows){
2164                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2165                   buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2166                }
2167
2168
2169                if(nextQuestionType === 'checkbox' && nextArrowIsDisabled && nextButtonIsDisabled){
2170                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2171                }
2172                if(nextQuestionType === 'checkbox' && enableArrows){
2173                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2174                   buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2175                }
2176
2177                if(nextQuestionType === 'number' && nextArrowIsDisabled && nextButtonIsDisabled){
2178                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2179                }
2180                if(nextQuestionType === 'number' && enableArrows){
2181                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2182                   buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2183                }
2184
2185                if(nextQuestionType === 'text' && nextArrowIsDisabled && nextButtonIsDisabled){
2186                   next_fs.find('.ays_buttons_div').find('input.ays_next').removeClass('ays_display_none');
2187                }
2188                if(nextQuestionType === 'text' && enableArrows){
2189                   next_fs.find('.ays_buttons_div').find('input.ays_next').addClass('ays_display_none');
2190                   next_fs.find('.ays_buttons_div').find('i.ays_next_arrow').removeClass('ays_display_none');
2191                }
2192
2193                if(nextQuestionType === 'date' && nextArrowIsDisabled && nextButtonIsDisabled){
2194                    buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2195                }
2196                if(nextQuestionType === 'date' && enableArrows){
2197                    buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2198                    buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2199                }
2200
2201                var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
2202                var checkUserAnswered = false;
2203                if (next_fs.find('.ays-quiz-answers .ays-field textarea').length) {
2204                    nextQuestionType = 'text';
2205                }
2206                if (next_fs.find('.ays-quiz-answers .ays-field select.ays-select').length) {
2207                    nextQuestionType = 'select';
2208                }
2209                
2210                if ( next_fs.hasClass('ays-custom-step') ) {
2211                    nextQuestionType = 'custom';
2212                }
2213
2214                switch (nextQuestionType){
2215                    case "radio":
2216                        checkUserAnswered = next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').is(':checked');
2217                    break;
2218                    case "checkbox":
2219                        checkUserAnswered = next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').is(':checked');
2220                    break;
2221                    case "number":
2222                        var questionTypeVal = next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').val().length;
2223                        if (questionTypeVal !== 0) {
2224                            checkUserAnswered = true;
2225                        }
2226                    break;
2227                    case "text":
2228                        var questionTypeVal = next_fs.find('.ays-quiz-answers .ays-field textarea, .ays-quiz-answers .ays-field input[type="text"]').val();
2229                        if (questionTypeVal !== '') {
2230                            checkUserAnswered = true;
2231                        }
2232                    break;
2233                    case "date":
2234                        var questionTypeVal = next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').val().length;
2235                        if (questionTypeVal !== 0) {
2236                            checkUserAnswered = true;
2237                        }
2238                    break;
2239                    case "select":
2240                        var questionTypeEl = next_fs.find('.ays-quiz-answers .ays-field select.ays-select option[data-chisht]');
2241                        questionTypeEl.each(function(){
2242                            var questionTypeVal = $(this).attr('selected');
2243                            if (questionTypeVal) {
2244                                checkUserAnswered = true;
2245                            }
2246                        });
2247                    break;
2248                    case "custom":
2249                        checkUserAnswered = true;
2250                    break;
2251                    default:
2252                        checkUserAnswered = next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').prop('ckecked');
2253                    break;
2254                }
2255                if(isRequiredQuestion === true){
2256                    if(next_fs.find('.information_form').length === 0){
2257                        if(enableArrows){
2258                            if (! checkUserAnswered) {
2259                                buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
2260                            }else{
2261                                if( nextQuestionType == 'custom' ){
2262                                    buttonsDiv.find('i.ays_next').removeAttr('disabled');
2263                                    buttonsDiv.find('i.ays_finish').removeAttr('disabled');
2264                                }
2265                                buttonsDiv.find('i.ays_early_finish').removeAttr('disabled');
2266                            }
2267                        }else{
2268                            if (! checkUserAnswered) {
2269                                buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
2270                            }else{
2271                                if( nextQuestionType == 'custom' ){
2272                                    buttonsDiv.find('input.ays_next').removeAttr('disabled');
2273                                    buttonsDiv.find('input.ays_finish').removeAttr('disabled');
2274                                }
2275                                buttonsDiv.find('input.ays_early_finish').removeAttr('disabled');
2276                            }
2277                        }
2278                    }
2279                }
2280
2281                aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs);
2282                next_fs.find('.ays-text-input').trigger( "focus" );
2283                if ( ! next_fs.find('.ays-text-input').is(":focus") ) {
2284                    setTimeout(function(e){
2285                        next_fs.find('.ays-text-input').trigger( "focus" );
2286                    },1001);
2287                }
2288
2289                setTimeout(function(){
2290                    if(next_fs.find('.ays-text-field').length > 0){
2291                        if(next_fs.find('.ays-text-field').width() < 250){
2292                            next_fs.find('.ays-text-field').css({
2293                                'flex-wrap': 'wrap',
2294                                'justify-content': 'center',
2295                                'padding': '5px'
2296                            });
2297                            next_fs.find('.ays-text-field').find('input.ays-text-input').css('margin-bottom', '5px');
2298                        }
2299                    }
2300                },2000);
2301            }
2302            
2303            if($(document).scrollTop() >= $(this).parents('.ays-questions-container').offset().top || $(this).parents('.ays-questions-container').offset().top > 500){
2304                ays_quiz_container.goTo( myOptions );
2305            }
2306            if(current_fs.find('audio').length > 0){
2307                current_fs.find('audio').each(function(e, el){
2308                    el.pause();
2309                });
2310            }
2311            if(current_fs.find('video').length > 0){
2312                current_fs.find('video').each(function(e, el){
2313                    el.pause();
2314                });
2315            }
2316
2317            //Current
2318            if(current_fs.find('audio').length > 0){
2319                var sound_src = next_fs.find('audio').attr('src');
2320                if (typeof sound_src !== 'undefined'){
2321                    var audio = next_fs.find('audio').get(0);
2322                    audio.pause();
2323                    audio.currentTime = 0;
2324                }
2325            }
2326
2327            //Next
2328            var enableAudioAutoplay = (myOptions.enable_audio_autoplay && myOptions.enable_audio_autoplay == 'on') ? true : false;
2329            if(next_fs.find('audio').length > 0){
2330                if(enableAudioAutoplay){
2331                    var sound_src = next_fs.find('audio').attr('src');
2332                    if (typeof sound_src !== 'undefined'){
2333                        var audio = next_fs.find('audio').get(0);
2334                        audio.currentTime = 0;
2335                        audio.play();
2336                    }
2337                }
2338            }
2339
2340            //Custom type
2341            //Checking Next button and Arrows filelds
2342            var enableNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == 'off') ? true : false;
2343            var enableArrows = (myOptions.enable_arrows && myOptions.enable_arrows == 'on') ? true : false;
2344            if(enableNextButton){
2345                if(next_fs.hasClass('ays-custom-step')){
2346                    if (enableArrows) {
2347                        next_fs.find('.ays_buttons_div i.ays_next.action-button.ays_arrow').removeClass('ays_display_none');
2348                    }else{
2349                        next_fs.find('.ays_buttons_div input.ays_next.action-button').removeClass('ays_display_none');
2350                    }
2351                }
2352            }
2353
2354        });
2355
2356
2357        $(document).find('.ays_questions_nav_question').on('click', function(e){
2358            e.preventDefault();
2359            var questionId = $(this).data('id');
2360            ays_quiz_container = $(this).parents(".ays-quiz-wrap").find(".ays-quiz-container");
2361
2362            if (animating) return false;
2363            animating = true;
2364            current_fs = ays_quiz_container.find('div.active-step[data-question-id]');
2365            next_fs = ays_quiz_container.find('div[data-question-id="'+questionId+'"]');
2366
2367                current_fs.removeClass('active-step');
2368                next_fs.addClass('active-step');
2369                var nextQuestionType = next_fs.find('input[name^="ays_questions"]').attr('type');
2370                var buttonsDiv = next_fs.find('.ays_buttons_div');
2371                var enableArrows = $(document).find(".ays-questions-container .ays_qm_enable_arrows").val();
2372
2373                var questions_count = $(this).parents('.ays-quiz-wrap').find('div[data-question-id]').length;
2374                var curent_number = $(this).parents('.ays-quiz-wrap').find('div[data-question-id]').index( ays_quiz_container.find('div[data-question-id="'+questionId+'"]') );
2375
2376                var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width();
2377                var final_width = ((curent_number+1) / questions_count * 100) + "%";
2378
2379                if( ays_quiz_container.find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
2380                    ays_quiz_container.find('.ays-live-bar-percent').text(parseInt(curent_number+1));
2381                }else{
2382                    ays_quiz_container.find('.ays-live-bar-percent').text(parseInt(final_width));
2383                }
2384                ays_quiz_container.find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
2385
2386                if ( next_fs.hasClass('ays-custom-step') ) {
2387                    nextQuestionType = 'custom';
2388                }
2389
2390                if(myOptions.enable_arrows){
2391                    enableArrows = myOptions.enable_arrows == 'on' ? true : false;
2392                }else{
2393                    enableArrows = parseInt(enableArrows) == 1 ? true : false;
2394                }
2395                var nextArrowIsDisabled = buttonsDiv.find('.ays_next_arrow').hasClass('ays_display_none');
2396                var nextButtonIsDisabled = buttonsDiv.find('.ays_next').hasClass('ays_display_none');
2397
2398                if(next_fs.find('textarea[name^="ays_questions"]').attr('type')==='text' && nextArrowIsDisabled && nextButtonIsDisabled){
2399                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2400                }
2401                if(next_fs.find('textarea[name^="ays_questions"]').attr('type')==='text' && enableArrows){
2402                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2403                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2404                }
2405
2406
2407                if(nextQuestionType === 'checkbox' && nextArrowIsDisabled && nextButtonIsDisabled){
2408                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2409                }
2410                if(nextQuestionType === 'checkbox' && enableArrows){
2411                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2412                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2413                }
2414
2415                if(nextQuestionType === 'number' && nextArrowIsDisabled && nextButtonIsDisabled){
2416                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2417                }
2418                if(nextQuestionType === 'number' && enableArrows){
2419                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2420                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2421                }
2422
2423                if(nextQuestionType === 'text' && nextArrowIsDisabled && nextButtonIsDisabled){
2424                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2425                }
2426                if(nextQuestionType === 'text' && enableArrows){
2427                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2428                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2429                }
2430
2431                if(nextQuestionType === 'short_text' && nextArrowIsDisabled && nextButtonIsDisabled){
2432                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2433                }
2434                if(nextQuestionType === 'short_text' && enableArrows){
2435                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2436                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2437                }
2438
2439                if(nextQuestionType === 'date' && nextArrowIsDisabled && nextButtonIsDisabled){
2440                    buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2441                }
2442                if(nextQuestionType === 'date' && enableArrows){
2443                    buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2444                    buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2445                }
2446
2447                if(enableArrows){
2448                    if( nextQuestionType == 'custom' ){
2449                        buttonsDiv.find('i.ays_next').removeAttr('disabled');
2450                        buttonsDiv.find('i.ays_finish').removeAttr('disabled');
2451                        buttonsDiv.find('i.ays_early_finish').removeAttr('disabled');
2452                    }
2453                }else{
2454                    if( nextQuestionType == 'custom' ){
2455                        buttonsDiv.find('input.ays_next').removeAttr('disabled');
2456                        buttonsDiv.find('input.ays_finish').removeAttr('disabled');
2457                        buttonsDiv.find('input.ays_early_finish').removeAttr('disabled');
2458                    }
2459                }
2460
2461                aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs);
2462                next_fs.find('.ays-text-input').trigger( "focus" );
2463                setTimeout(function(){
2464                    if(next_fs.find('.ays-text-field').length > 0){
2465                        if(next_fs.find('.ays-text-field').width() < 250){
2466                            next_fs.find('.ays-text-field').css({
2467                                'flex-wrap': 'wrap',
2468                                'justify-content': 'center',
2469                                'padding': '5px'
2470                            });
2471                            next_fs.find('.ays-text-field').find('input.ays-text-input').css('margin-bottom', '5px');
2472                        }
2473                    }
2474                },2000);
2475            // }
2476
2477            // if($(document).scrollTop() >= $(this).parents('.ays-questions-container').offset().top || $(this).parents('.ays-questions-container').offset().top > 500){
2478            //     ays_quiz_container.goTo();
2479            // }
2480            if(current_fs.find('audio').length > 0){
2481                current_fs.find('audio').each(function(e, el){
2482                    el.pause();
2483                });
2484            }
2485            if(current_fs.find('video').length > 0){
2486                current_fs.find('video').each(function(e, el){
2487                    el.pause();
2488                });
2489            }
2490        });
2491
2492        $(document).find('.ays_previous').on("click", function(e){
2493            ays_quiz_container = $(this).parents(".ays-quiz-container");
2494
2495            var enableArrows = ays_quiz_container.find(".ays-questions-container .ays_qm_enable_arrows").val();
2496            if(myOptions.enable_arrows){
2497                enableArrows = myOptions.enable_arrows == 'on' ? true : false;
2498            }else{
2499                enableArrows = parseInt(enableArrows) == 1 ? true : false;
2500            }
2501
2502            if(typeof explanationTimeout != 'undefined'){
2503                clearTimeout(explanationTimeout);
2504
2505                var thisButtonsDiv = $(this).parents(".ays_buttons_div");
2506                setTimeout(function(){
2507                    if (thisButtonsDiv.find('input.ays_next').hasClass('ays_display_none') &&
2508                        thisButtonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none')) {
2509                        if(enableArrows){
2510                            thisButtonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2511                        }else{
2512                            thisButtonsDiv.find('input.ays_next').removeClass('ays_display_none');
2513                        }
2514                    }
2515                }, 1000);
2516            }
2517
2518            if(animating) return false;
2519            animating = true;
2520
2521            var next_sibilings_count = ays_quiz_container.find('.ays_question_count_per_page').val();
2522            if(parseInt(next_sibilings_count)>0 && ($(this).parents('.step').attr('data-question-id') || $(this).parents('.step').next().attr('data-question-id'))){
2523                var questions_count = ays_quiz_container.find('div[data-question-id]').length;
2524                var curent_number_of_this = ays_quiz_container.find('div[data-question-id]').index($(this).parents('div[data-question-id]')) + 1;
2525                var curent_number = ays_quiz_container.find('div[data-question-id]').index($(this).parents('div[data-question-id]')) - parseInt(next_sibilings_count) + 1;
2526                var count_per_page = questions_count%parseInt(next_sibilings_count);
2527                var nextCountQuestionsPerPage = questions_count-curent_number;
2528                if(count_per_page > 0 && curent_number_of_this == questions_count){
2529                    curent_number = ays_quiz_container.find('div[data-question-id]').index($(this).parents('div[data-question-id]')) - count_per_page + 1;
2530                }
2531                if (!($(this).hasClass('start_button'))) {
2532                    var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width();
2533                    var final_width = ((curent_number) / questions_count * 100) + "%";
2534                    if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
2535                        $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number));
2536                    }else{
2537                        $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width));
2538                    }
2539                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
2540                }
2541                var current_fs_index = ays_quiz_container.find('div[data-question-id]').index(ays_quiz_container.find('.active-step').eq(0));
2542                if($(this).parents('.step').attr('data-question-id')){
2543                    current_fs = ays_quiz_container.find('div[data-question-id]').slice(current_fs_index,current_fs_index+parseInt(next_sibilings_count));
2544                }else{
2545                    current_fs = $(this).parents('.step');
2546                }
2547
2548                var current_first_fs_index = ays_quiz_container.find('div[data-question-id]').index(ays_quiz_container.find('.active-step').eq(0));
2549                var next_fs = ays_quiz_container.find('div[data-question-id]').slice((current_first_fs_index - parseInt(next_sibilings_count)), current_first_fs_index);
2550                
2551                var buttonsDiv = next_fs.find('.ays_buttons_div');
2552                var enableArrows = $(document).find(".ays-questions-container .ays_qm_enable_arrows").val();
2553                if(myOptions.enable_arrows){
2554                    enableArrows = myOptions.enable_arrows == 'on' ? true : false;
2555                }else{
2556                    enableArrows = parseInt(enableArrows) == 1 ? true : false;
2557                }
2558
2559                if (buttonsDiv.find('input.ays_next').hasClass('ays_display_none') &&
2560                    buttonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none')) {
2561                    if(enableArrows){
2562                        buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2563                    }else{
2564                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2565                    }
2566                }
2567
2568                ays_quiz_container.find('div[data-question-id]').eq(current_fs_index).removeClass('active-step');
2569                next_fs.eq(0).addClass('active-step')
2570                if ($(this).parents('form').hasClass('enable_correction')) {
2571                    if (next_fs.find('.correct').length !== 0 || $(this).parents('div[data-question-id]').prev().find('.wrong').length !== 0) {
2572                        next_fs.find('input[name^="ays_questions"]').on('click',function () {
2573                            var is_user_answer_correct = $(this).parent().find('.correct').length;
2574                            var is_user_answer_wrong = $(this).parent().find('.wrong').length;
2575                            if (is_user_answer_correct !== 0 || is_user_answer_wrong !== 0) {
2576                                return false;
2577                            }
2578                        });
2579                    }
2580                }
2581
2582                if ($(this).parents('form').hasClass('enable_correction')) {
2583                    next_fs.find('input[name^="ays_questions"]').each(function(){
2584                        if ($(this).parents('.ays-quiz-answers').find('.correct').length === 0 &&
2585                            $(this).parents('.ays-quiz-answers').find('.wrong').length === 0 &&
2586                            $(this).parents('.ays-quiz-answers').find('.ays-answered-text-input').length === 0) {
2587                            $(this).attr('disabled', false);
2588                        }
2589                    });
2590                }
2591                
2592                aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs);
2593                next_fs.eq(0).find('.ays-text-input').trigger( "focus" );
2594                
2595                next_fs.eq(0).find('.ays-text-input').trigger( "focus" );
2596                if ( ! next_fs.eq(0).find('.ays-text-input').is(":focus") ) {
2597                    setTimeout(function(e){
2598                        next_fs.eq(0).find('.ays-text-input').trigger( "focus" );
2599                    },1001);
2600                }
2601            }else{
2602                if ($(this).parents('div[data-question-id]').prev().find('.correct').length === 0 &&
2603                    $(this).parents('div[data-question-id]').prev().find('.wrong').length === 0 &&
2604                    $(this).parents('div[data-question-id]').prev().find('.ays-answered-text-input').length === 0) {
2605                    $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"]').attr('disabled', false);
2606                }else{
2607                    $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"]').attr('disabled', true);
2608                    if( $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"]').attr('type') == 'checkbox' ){
2609                        $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"]').attr('disabled', false);
2610                        $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"][type="radio"]').on('click',function () {
2611                            return false;
2612                        });
2613                    }
2614                }
2615
2616                current_fs = $(this).parents('.step');
2617                next_fs = $(this).parents('.step').prev();
2618
2619
2620                if( aysThisQuizBullets !== null ){
2621                    var thisQuestionID = next_fs.data('questionId');
2622                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]').parent();
2623                    aysThisQuizBullets._navPage(thisBullet.index());
2624                }
2625
2626                var buttonsDiv = next_fs.find('.ays_buttons_div');
2627
2628                if (buttonsDiv.find('input.ays_next').hasClass('ays_display_none') &&
2629                    buttonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none')) {
2630                    if(enableArrows){
2631                        buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2632                        buttonsDiv.find('i.ays_next_arrow').removeAttr('disabled');
2633                        buttonsDiv.find('i.ays_early_finish').removeAttr('disabled');
2634                        buttonsDiv.find('i.ays_next_arrow').removeProp('disabled');
2635                        buttonsDiv.find('i.ays_early_finish').removeProp('disabled');
2636                    }else{
2637                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2638                        buttonsDiv.find('input.ays_next').removeAttr('disabled');
2639                        buttonsDiv.find('input.ays_early_finish').removeAttr('disabled');
2640                        buttonsDiv.find('input.ays_next').removeProp('disabled');
2641                        buttonsDiv.find('input.ays_early_finish').removeProp('disabled');
2642                    }
2643                }
2644
2645                if (current_fs.hasClass('ays-abs-fs')) {
2646                    current_fs = $(this).parents('.step');
2647                    next_fs = $(this).parents('.step').prev();
2648                    var counterClass = "";
2649                    switch(ays_quiz_container.data('questEffect')){
2650                        case "shake":
2651                            counterClass = ays_quiz_container.data('questEffect');
2652                        break;
2653                        case "fade":
2654                            counterClass = "fadeIn";
2655                        break;
2656                        case "none":
2657                            counterClass = "";
2658                        break;
2659                        default:
2660                            counterClass = ays_quiz_container.data('questEffect');
2661                        break;
2662                    }
2663                    next_fs.find('.ays-question-counter').addClass(counterClass);
2664                }
2665                current_fs.removeClass('active-step');
2666                next_fs.addClass('active-step');
2667
2668                var questions_count = $(this).parents('form').find('div[data-question-id]').length;
2669                var curent_number = $(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]'))-1;
2670                if(curent_number != questions_count){
2671                    if(($(this).hasClass('ays_finish')) == false){
2672                        if (!($(this).hasClass('start_button'))) {
2673                            var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width();
2674                            var final_width = ((curent_number+1) / questions_count * 100) + "%";
2675                            if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
2676                                $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+1));
2677                            }else{
2678                                $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width));
2679                            }
2680                            $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
2681                        }
2682                    }
2683                }else{
2684                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut');
2685                    setTimeout(function () {
2686                        $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none');
2687                    },300)
2688                }
2689                aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs);
2690                next_fs.find('.ays-text-input').trigger( "focus" );
2691
2692                next_fs.find('.ays-text-input').trigger( "focus" );
2693                if ( ! next_fs.find('.ays-text-input').is(":focus") ) {
2694                    setTimeout(function(e){
2695                        next_fs.find('.ays-text-input').trigger( "focus" );
2696                    },1001);
2697                }
2698            }
2699            if($(document).scrollTop() >= $(this).parents('.ays-questions-container').offset().top || $(this).parents('.ays-questions-container').offset().top > 500){
2700                ays_quiz_container.goTo( myOptions );
2701            }
2702            if(current_fs.find('audio').length > 0){
2703                current_fs.find('audio').each(function(e, el){
2704                    el.pause();
2705                });
2706            }
2707            if(current_fs.find('video').length > 0){
2708                current_fs.find('video').each(function(e, el){
2709                    el.pause();
2710                });
2711            }
2712
2713            //Current
2714            if(current_fs.find('audio').length > 0){
2715                var sound_src = next_fs.find('audio').attr('src');
2716                if (typeof sound_src !== 'undefined'){
2717                    var audio = next_fs.find('audio').get(0);
2718                    audio.pause();
2719                    audio.currentTime = 0;
2720                }
2721            }
2722
2723            //Previous
2724            var enableAudioAutoplay = (myOptions.enable_audio_autoplay && myOptions.enable_audio_autoplay == 'on') ? true : false;
2725            if(next_fs.find('audio').length > 0){
2726                if(enableAudioAutoplay){
2727                    var sound_src = next_fs.find('audio').attr('src');
2728                    if (typeof sound_src !== 'undefined'){
2729                        var audio = next_fs.find('audio').get(0);
2730                        audio.currentTime = 0;
2731                        audio.play();
2732                    }
2733                }
2734            }
2735        });
2736
2737        $(document).find('.ays-quiz-container input').on('focus',function () {
2738            $(window).on('keydown',function (event) {
2739                if(event.keyCode === 13){
2740                    return false;
2741                }
2742            });
2743        });
2744
2745        $(document).find('.ays-quiz-container input').on('blur',function () {
2746            $(window).off('keydown');
2747        });
2748        
2749        $(document).on('click', '.ays-quiz-container .ays_question_hint', function (e) {
2750            e.preventDefault();
2751            $(e.target).parents('.ays-quiz-container').find('.ays_music_sound').toggleClass('z_index_0');
2752            $(e.target).parent().find('.ays_question_hint_text').toggleClass('show_hint');
2753            if($(e.target).parent().find('.ays_question_hint_text').hasClass('show_hint')){
2754                $(window).on('click', function(ev){
2755                    if( ! ( $(ev.target).hasClass('ays_question_hint_text') || $(ev.target).hasClass('ays_question_hint') ) ){
2756                        $(e.target).parent().find('.ays_question_hint_text').removeClass('show_hint')
2757                        $(e.target).parents('.ays-quiz-container').find('.ays_music_sound').removeClass('z_index_0');
2758                    }
2759                });
2760            }
2761        });
2762
2763        $(document).on('click', '.ays-field', function() {
2764            if ($(this).find(".select2").hasClass('select2-container--open')) {
2765                $(this).find('b[role="presentation"]').removeClass('ays_fa ays_fa_chevron_down');
2766                $(this).find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_up');
2767            } else {
2768                $(this).find('b[role="presentation"]').removeClass('ays_fa ays_fa_chevron_up');
2769                $(this).find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down');
2770            }
2771        });
2772
2773        $(document).find('select.ays-select').on("select2:selecting", function(e){
2774            $(this).parents('.ays-quiz-container').find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down');
2775        });
2776        
2777        $(document).find('select.ays-select').on("select2:opening", function(e){
2778            $(this).parents('.ays-quiz-container').css('z-index', 1);
2779            $(this).parents('.step').css('z-index', 1);
2780        });
2781
2782        $(document).find('select.ays-select').on("select2:closing", function(e){
2783            $(this).parents('.ays-quiz-container').find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down');
2784            $(this).parents('.ays-quiz-container').css('z-index', 'initial');
2785            $(this).parents('.step').css('z-index', 'initial');
2786        });
2787        
2788        $(document).find('select.ays-select').on("select2:select", function(e){
2789            var quizContainer = $(e.target).parents('.ays-quiz-container');
2790            var right_answer_sound = quizContainer.find('.ays_quiz_right_ans_sound').get(0);
2791            var wrong_answer_sound = quizContainer.find('.ays_quiz_wrong_ans_sound').get(0);
2792            var finishAfterWrongAnswer = (myOptions.finish_after_wrong_answer && myOptions.finish_after_wrong_answer == "on") ? true : false;
2793            var showOnlyWrongAnswer = (myOptions.show_only_wrong_answer && myOptions.show_only_wrong_answer == "on") ? true : false;
2794            var explanationTime = myOptions.explanation_time && myOptions.explanation_time != "" ? parseInt(myOptions.explanation_time) : 4;
2795            var next_sibilings_count = quizContainer.find('.ays_question_count_per_page').val();
2796            var enableNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == 'on') ? true : false;
2797            var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
2798            var thankYouStep = quizContainer.find('div.step.ays_thank_you_fs');
2799            var infoFormLast = thankYouStep.prev().find('div.information_form');
2800
2801            // Display all questions on one page
2802            myOptions.quiz_display_all_questions = ( myOptions.quiz_display_all_questions ) ? myOptions.quiz_display_all_questions : 'off';
2803            var quiz_display_all_questions = (myOptions.quiz_display_all_questions && myOptions.quiz_display_all_questions == "on") ? true : false;
2804
2805            var disableQuestions = false;
2806            if( parseInt( next_sibilings_count ) > 0 || quiz_display_all_questions == true ){
2807                disableQuestions = true;
2808            }
2809
2810            $(this).parent().find('.ays-select-field-value').attr("value", $(this).val());
2811            if($(this).parents(".ays-questions-container").find('form[id^="ays_finish_quiz"]').hasClass('enable_correction')) {
2812                var chishtPatasxan = $(this).find('option:selected').data("chisht");
2813                if (chishtPatasxan == 1) {
2814                    if((right_answer_sound)){
2815                        resetPlaying([right_answer_sound, wrong_answer_sound]);
2816                        setTimeout(function(){
2817                            right_answer_sound.play();
2818                        }, 10);
2819                    }
2820                    $(this).parents('.ays-field').addClass('correct_div checked_answer_div');
2821                    $(this).parents('.ays-field').find('.select2-selection__rendered').css("background-color", "rgba(0, 128, 0, 0.6)");
2822                } else {
2823                    if((wrong_answer_sound)){
2824                        resetPlaying([right_answer_sound, wrong_answer_sound]);
2825                        setTimeout(function(){
2826                            wrong_answer_sound.play();
2827                        }, 10);
2828                    }
2829                    $(this).parents('.ays-field').addClass('wrong_div checked_answer_div');
2830                    $(this).parents('.ays-field').find('.select2-selection__rendered').css("background-color", "rgba(255, 2, 2, 0.6)");
2831                    if(showOnlyWrongAnswer === false){
2832                        var rightAnswerText = '<div class="ays-text-right-answer">'+
2833                            $(this).find('option[data-chisht="1"]').html()+
2834                            '</div>';
2835                        $(this).parents('.ays-quiz-answers').append(rightAnswerText);
2836                        $(this).parents('.ays-quiz-answers').find('.ays-text-right-answer').css("text-align", "left");
2837                        $(this).parents('.ays-quiz-answers').find('.ays-text-right-answer').slideDown(500);
2838                    }
2839                }
2840                if (chishtPatasxan == 1){
2841                    if( aysThisQuizBullets !== null ){
2842                        var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
2843                        var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
2844                        thisBullet.attr('disabled', 'disabled');
2845                        thisBullet.addClass('ays_quiz_correct_answer');
2846                        thisBullet.parent().addClass('ays_quiz_checked_answer_div');
2847                    }
2848                }else{
2849                    if( aysThisQuizBullets !== null ){
2850                        var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
2851                        var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
2852                        thisBullet.attr('disabled', 'disabled');
2853                        thisBullet.addClass('ays_quiz_wrong_answer');
2854                        thisBullet.parent().addClass('ays_quiz_checked_answer_div');
2855                    }
2856                }
2857
2858                if(myOptions.answers_rw_texts && (myOptions.answers_rw_texts == 'on_passing' || myOptions.answers_rw_texts == 'on_both')){
2859                    if (chishtPatasxan == 1) {
2860                        $(e.target).parents().eq(3).find('.right_answer_text').slideDown(500);
2861                    }
2862                    else {
2863                        $(e.target).parents().eq(3).find('.wrong_answer_text').slideDown(500);
2864                    }
2865                }
2866                if(finishAfterWrongAnswer && chishtPatasxan != 1){
2867                    $(e.target).parents('div[data-question-id]').find('.ays_
2867next').attr('disabled', 'disabled');
2868                    $(e.target).parents('div[data-question-id]').find('.ays_early_finish').attr('disabled', 'disabled');
2869                    $(e.target).parents('div[data-question-id]').find('.ays_previous').attr('disabled', 'disabled');
2870                    if( disableQuestions ){
2871                        quizContainer.find('div[data-question-id]').css('pointer-events', 'none');
2872                    }
2873                    if( aysThisQuizBullets !== null ){
2874                        aysThisQuizBullets.baseElement.find('.ays_questions_nav_question').each(function(){
2875                            var thisBullet = $(this);
2876                            thisBullet.attr('disabled', 'disabled');
2877                        });
2878                    }
2879                }
2880                explanationTimeout = setTimeout(function(){
2881                    if (chishtPatasxan == 1) {
2882                        if ($(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
2883                            $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
2884                            $(e.target).parents('div[data-question-id]').find('.ays_next').trigger('click');
2885                        } else if ( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
2886                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
2887                            if ( existsEmtpyQuestions ) {
2888                                if(infoFormLast.length == 0){
2889                                    quizContainer.find('input.ays_finish').trigger('click');
2890                                } else {
2891                                    quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
2892                                }
2893                            }
2894                        }
2895                    }else{
2896                        if(finishAfterWrongAnswer){
2897                            goToLastPage(e);
2898                        }else{
2899                            if ($(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
2900                                $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
2901                                $(e.target).parents('div[data-question-id]').find('.ays_next').trigger('click');
2902                            } else if ( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
2903                                var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
2904                                if ( existsEmtpyQuestions ) {
2905                                    if(infoFormLast.length == 0){
2906                                        quizContainer.find('input.ays_finish').trigger('click');
2907                                    } else {
2908                                        quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
2909                                    }
2910                                }
2911                            }
2912                        }
2913                    }
2914                }, explanationTime*1000);
2915                var showExplanationOn = (myOptions.show_questions_explanation && myOptions.show_questions_explanation != "") ? myOptions.show_questions_explanation : "on_results_page";
2916                if(showExplanationOn == 'on_passing' || showExplanationOn == 'on_both'){
2917                    if(! $(this).parents('.step').hasClass('not_influence_to_score')){
2918                        $(this).parents('.step').find('.ays_questtion_explanation').slideDown(250);
2919                    }
2920                }
2921                $(this).attr("disabled", true);
2922            }else{
2923                if ($(this).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
2924                    $(this).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
2925                    $(this).parents('div[data-question-id]').find('.ays_
2925next').trigger('click');
2926                }
2927                if( $(this).find('option:selected').length > 0 ){
2928                    var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
2929                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
2930                    thisBullet.parent().addClass('ays-quiz-questions-nav-item-answered');
2931                }else{
2932                    var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
2933                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
2934                    thisBullet.parent().removeClass('ays-quiz-questions-nav-item-answered');
2935                }
2936
2937            }
2938
2939            if(isRequiredQuestion === true){
2940                if($(this).find('option:selected').length != 0){
2941                    if (!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
2942                        $(e.target).parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled');
2943                        $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled');
2944                    }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
2945                        $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled');
2946                        $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled');
2947                    }
2948                }else{
2949                    if (!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
2950                        $(e.target).parents('div[data-question-id]').find('input.ays_next').attr('disabled', true);
2951                        $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', true);
2952                    }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
2953                        $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', true);
2954                        $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', true);
2955                    }
2956                }
2957            }
2958
2959            var this_select_value = $(this).val();
2960            $(this).find("option").removeAttr("selected");
2961            $(this).find("option[value='"+this_select_value+"']").attr("selected", true);
2962        });
2963
2964        function aysSelectDropdownCheck(select){
2965            var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
2966            if(isRequiredQuestion === true){
2967                if(select.val() != ''){
2968                    if (!select.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
2969                        select.parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled');
2970                        select.parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled');
2971                    }else if(!select.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
2972                        select.parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled');
2973                        select.parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled');
2974                    }
2975                }else{
2976                    if (!select.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
2977                        select.parents('div[data-question-id]').find('input.ays_next').attr('disabled', true);
2978                        select.parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', true);
2979                    }else if(!select.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
2980                        select.parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', true);
2981                        select.parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', true);
2982                    }
2983                }
2984            }
2985        }
2986
2987        // var shareButtons = document.querySelectorAll(".ays-share-btn.ays-to-share");
2988        $(document).on('click', ".ays-share-btn.ays-to-share", function (event){
2989            var width = 650,
2990                height = 450;
2991
2992            event.preventDefault();
2993
2994            window.open(this.href, quizLangObj.shareDialog, 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width='+width+',height='+height+',top='+(screen.height/2-height/2)+',left='+(screen.width/2-width/2));
2995        });
2996
2997        // if (shareButtons) {
2998        //     [].forEach.call(shareButtons, function(button) {
2999        //         button.addEventListener("click", function(event) {
3000        //             var width = 650,
3001        //                 height = 450;
3002
3003        //             event.preventDefault();
3004
3005        //             window.open(this.href, quizLangObj.shareDialog, 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width='+width+',height='+height+',top='+(screen.height/2-height/2)+',left='+(screen.width/2-width/2));
3006        //         });
3007        //     });
3008        // }
3009
3010        $(document).find('.ays-quiz-container').map(function () {
3011            $(this).find('div[data-question-id]').eq(0).find('.ays_previous').css({'display':'none'});
3012            var next_sibilings_count = parseInt($(this).find('.ays_question_count_per_page').val());
3013            if(next_sibilings_count>0){
3014                $(this).find('div[data-question-id]').eq(next_sibilings_count-1).find('.ays_previous').css({'display':'none'});
3015            }
3016        });
3017
3018        $(document).on('click', '.ays_finish.action-button.ays_arrow', function () {
3019            $(this).parents('.ays_buttons_div').find('input.ays_next.action-button').trigger('click');
3020        });
3021
3022        $(document).find('div[data-question-id]').map(function () {
3023            $(this).find('.ays-quiz-answers .ays-field').map(function () {
3024                if($(this).find('label[for^="ays-answer"]').eq(1).find('img').length !== 0){
3025                    $(this).find('label[for^="ays-answer"]').eq(0).addClass('ays_empty_before_content');
3026                    if($(this).find('label[for^="ays-answer"]').eq(0).text().length === 0){
3027                        $(this).find('label[for^="ays-answer"]').eq(0).css('background','transparent');
3028                    }
3029                }
3030            });
3031        });
3032        
3033        $(document).on('click', '.ays_finish.action-button', function () {
3034            var quizId = $(this).parents(".ays-quiz-container").find('input[name="ays_quiz_id"]').val();
3035            if ( typeof window.aysEarlyFinishConfirmBox != 'undefined') {
3036                if ( typeof window.aysEarlyFinishConfirmBox[ quizId ] != 'undefined' ) {
3037                    if( window.aysSeeResultConfirmBox[ quizId ] == true ){
3038                        $(this).addClass("ays_timer_end");
3039                    }
3040                }
3041            }
3042            if (typeof $(this).parents('.ays-quiz-container').find('.ays_
3042next.start_button').attr("data-enable-leave-page") !== 'undefined') {
3043                if(! $(this).parents('.ays-quiz-container').find('.step.active-step .ays-abs-fs.ays-end-page').hasClass('information_form')){
3044                    $(this).parents('.ays-quiz-container').find('.ays_next.start_button').attr("data-enable-leave-page",false);
3045                }
3046            }
3047        });
3048        
3049        $(document).on('click', '.ays_early_finish.action-button', function (e) {
3050            e.preventDefault();
3051            var quizId = $(this).parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
3052
3053            if (typeof $(this).parents('.ays-quiz-container').find('.ays_next.start_button').attr("data-enable-leave-page") !== 'undefined') {
3054                if(! $(this).parents('.ays-quiz-container').find('.step .ays-abs-fs.ays-end-page').hasClass('information_form')){
3055                    $(this).parents('.ays-quiz-container').find('.ays_next.start_button').attr("data-enable-leave-page",false);
3056                }
3057            }
3058            var confirm;
3059            if (myOptions.enable_early_finsh_comfirm_box && myOptions.enable_early_finsh_comfirm_box == "off") {
3060                confirm = true;
3061            }else{
3062                confirm = window.confirm(quizLangObj.areYouSure);
3063            }
3064            if(confirm){
3065                clearTimeout(explanationTimeout);
3066                window.aysEarlyFinishConfirmBox[ quizId ] = true;
3067                var totalSteps = $(e.target).parents().eq(3).find('div.step').length;
3068                var currentStep = $(e.target).parents().eq(3).find('div.step.active-step');
3069                var thankYouStep = $(e.target).parents().eq(3).find('div.step.ays_thank_you_fs');
3070                var infoFormLast = thankYouStep.prev().find('div.information_form');
3071                var questions_count = $(e.target).parents('form').find('div[data-question-id]').length;
3072                $(this).parents('.ays-quiz-container').find('.ays_finish.action-button').addClass("ays_timer_end");
3073                if($(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
3074                    $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(questions_count);
3075                }else{
3076                    $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({
3077                        width: '100%'
3078                    });
3079                    $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(100);
3080                }
3081                currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').slideUp();
3082                setTimeout(function () {
3083                    currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').parent().hide();
3084                },300);
3085                if(infoFormLast.length == 0){
3086                    if (currentStep.hasClass('ays_thank_you_fs') === false) {
3087                        var steps = totalSteps - 3;
3088                        $(e.target).parents().eq(3).find('div.step').each(function (index) {
3089                            if ($(this).hasClass('ays_thank_you_fs')) {
3090                                $(this).addClass('active-step')
3091                            }else{
3092                                $(this).css('display', 'none');
3093                            }
3094                        });
3095                        $(e.target).parents().eq(3).find('input.ays_finish').trigger('click');
3096                    }
3097                }else{
3098                    currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').parent().hide();
3099                    $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut');
3100                    setTimeout(function () {
3101                        $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none');
3102                    },300);
3103                    aysAnimateStep($(e.target).parents('.ays-quiz-container').data('quest-effect'), currentStep, infoFormLast.parent());
3104                    $(e.target).parents().eq(3).find('div.step').each(function (index) {
3105                        $(this).css('display', 'none');
3106                        $(this).removeClass('active-step')
3107                    });
3108                    infoFormLast.parent().css('display', 'flex');
3109                    infoFormLast.parent().addClass('active-step');
3110                    
3111                    $(this).parents(".ays-quiz-container").find('.ays_finish.action-button').addClass("ays_timer_end");
3112                    $(this).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').slide
3112Up(500);
3113                }
3114
3115                if($(document).scrollTop() >= $(this).parents('.ays-questions-container').offset().top || $(this).parents('.ays-questions-container').offset().top > 500){
3116                    $(this).parents(".ays-quiz-container").goTo( myOptions );
3117                }
3118            }
3119        });
3120        
3121        $(document).on('click', '.action-button.ays_restart_button', function () {
3122            window.location.reload();
3123        });
3124        
3125        $(document).on('click', '.action-button.ays_clear_answer', function () {
3126            var $this = $(this);
3127            var activeStep = $this.parents('.step');
3128            var inputs = activeStep.find('input[name^="ays_questions[ays-question-"]:checked');
3129            var checked_answer_divs = activeStep.find('div.ays-field.checked_answer_div');
3130            var ays_text_field = activeStep.find('div.ays-field.ays-text-field');
3131            var ays_select_field = activeStep.find('div.ays-field.ays-select-field');
3132            inputs.removeAttr('checked');
3133            inputs.trigger('change');
3134            checked_answer_divs.removeClass('checked_answer_div');
3135            ays_text_field.find('.ays-text-input').val('');
3136            ays_text_field.find('.ays-text-input').trigger('input');
3137            if(ays_select_field.find('select.ays-select').length > 0){
3138                ays_select_field.find('select.ays-select').val(null).trigger('change');
3139                var thisQuestionID = ays_select_field.parents('div[data-question-id]').data('questionId');
3140                var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
3141                thisBullet.parent().removeClass('ays-quiz-questions-nav-item-answered');
3142                aysSelectDropdownCheck(ays_select_field.find('select.ays-select'));
3143            }
3144        });
3145        
3146        $(document).on('click', '.ays_music_sound', function() {
3147            var $this = $(this);
3148            var quizCoutainer = $this.parents('.ays-quiz-container');
3149            var audioEls = $(document).find('audio.ays_quiz_music');
3150            var soundEls = $(document).find('.ays_music_sound');
3151            var audioEl = quizCoutainer.find('audio.ays_quiz_music').get(0);
3152            if($this.hasClass('ays_sound_active')){
3153                audioEl.volume = 0;
3154                $this.find('.ays_fa').addClass('ays_fa_volume_off').removeClass('ays_fa_volume_up');
3155                $this.removeClass('ays_sound_active');
3156            } else {
3157                audioEl.volume = 1;
3158                $this.find('.ays_fa').addClass('ays_fa_volume_up').removeClass('ays_fa_volume_off');
3159                $this.addClass('ays_sound_active');
3160            }
3161        });
3162
3163        function goToLastPage(e){
3164            clearTimeout(explanationTimeout);
3165            clearInterval(window.aysTimerInterval);
3166            var container = $(e.target).parents('.ays-quiz-container');
3167            var totalSteps = container.find('div.step').length;
3168            var currentStep = container.find('div.step.active-step');
3169            var thankYouStep = container.find('div.step.ays_thank_you_fs');
3170            var infoFormLast = thankYouStep.prev().find('div.information_form');
3171            var questions_count = $(e.target).parents('form').find('div[data-question-id]').length;
3172            if(container.find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
3173                container.find('.ays-live-bar-percent').text(questions_count);
3174            }else{
3175                container.find('.ays-live-bar-fill').animate({
3176                    width: '100%'
3177                });
3178                container.find('.ays-live-bar-percent').text(100);
3179            }
3180            container.find('.ays-quiz-timer').slideUp();
3181            setTimeout(function () {
3182                container.find('.ays-quiz-timer').parent().hide();
3183            },300);
3184
3185            if(infoFormLast.length == 0){
3186                if (currentStep.hasClass('ays_thank_you_fs') === false) {
3187                    var steps = totalSteps - 3;
3188                    container.find('div.step').each(function (index) {
3189                        if ($(this).hasClass('ays_thank_you_fs')) {
3190                            $(this).addClass('active-step')
3191                        }else{
3192                            $(this).css('display', 'none');
3193                        }
3194                    });
3195                    container.find('input.ays_finish').trigger('click');
3196                }
3197            }else{
3198                container.find('.ays-quiz-timer').parent().hide();
3199                container.find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut');
3200                setTimeout(function () {
3201                    container.find('.ays-live-bar-wrap').css('display','none');
3202                },300);
3203                aysAnimateStep(container.data('quest-effect'), currentStep, infoFormLast.parent());
3204                container.find('div.step').each(function (index) {
3205                    $(this).css('display', 'none');
3206                    $(this).removeClass('active-step')
3207                });
3208                infoFormLast.parent().css('display', 'flex');
3209                infoFormLast.parent().addClass('active-step');
3210
3211                $(e.target).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').slide
3211Up(500);
3212            }
3213        }
3214
3215        function ays_formatState (ays_state) {
3216            if(!ays_state.id) {
3217                return aysEscapeHtml(ays_state.text);
3218            }
3219            var baseUrl = $(ays_state.element).data('nkar');
3220            if(baseUrl != ''){
3221                var ays_state = $(
3222                    '<span><img src=' + baseUrl + ' class="ays_answer_select_image" /> ' + aysEscapeHtml(ays_state.text) + '</span>'
3223                );
3224            }else{
3225                var ays_state = $('<span>' + aysEscapeHtml(ays_state.text) + '</span>');
3226            }
3227            return ays_state;
3228        }
3229
3230        $(document).find('.ays-quiz-container').each(function(){
3231            var $this = $(this);
3232            var selectEl = $this.find('select.ays-select');
3233            selectEl.each(function(){
3234                $(this).select2({
3235                    placeholder: quizLangObj.selectPlaceholder,
3236                    dropdownParent: $(this).parents('.ays-abs-fs'),
3237                    templateResult: ays_formatState
3238                });
3239            });
3240        });
3241
3242        $(document).find('.ays-quiz-container b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down');
3243
3244        function aysResetQuiz ($quizContainer){
3245            var cont = $quizContainer.find('div[data-question-id]');
3246            cont.find('input[type="text"], textarea, input[type="number"], input[type="url"], input[type="email"]').each(function(){
3247                $(this).val('');
3248            });
3249            cont.find('select').each(function(){
3250                $(this).val('');
3251            });
3252            cont.find('select.ays-select').each(function(){
3253                $(this).val(null).trigger('change');
3254            });
3255            cont.find('select option').each(function(){
3256                $(this).removeAttr('selected');
3257            });
3258            cont.find('input[type="radio"], input[type="checkbox"]').each(function(){
3259                $(this).removeAttr('checked');
3260            });
3261        }
3262
3263        window.addEventListener("beforeunload", function (e) {
3264            var startButton = $(document).find('.ays-quiz-container .ays_next.start_button');
3265            var flag = false;
3266            for (var i = 0; i < startButton.length; i++) {
3267                var startBtn = startButton.eq(i).attr('data-enable-leave-page');
3268                if(typeof startBtn != undefined && startBtn === 'true'){
3269                    flag = true;
3270                    break;
3271                }
3272            }
3273
3274            if(flag){
3275                return true;
3276            }else{
3277                return null;
3278            }
3279        });
3280
3281        window.onbeforeunload =  function (e) {
3282            var startButton = $(document).find('.ays-quiz-container .ays_next.start_button');
3283            var flag = false;
3284            for (var i = 0; i < startButton.length; i++) {
3285                var startBtn = startButton.eq(i).attr('data-enable-leave-page');
3286                if(typeof startBtn != undefined && startBtn === 'true'){
3287                    flag = true;
3288                    break;
3289                }
3290            }
3291            if(flag){
3292                return true;
3293            }else{
3294                return null;
3295            }
3296        }
3297
3298        if( $(document).find('.ays-quiz-container').length > 0 ){
3299            var ays_quiz_autostart_interval = setInterval( function() {
3300                if (document.readyState === 'complete') {
3301                    var firstQuiz = $(document).find('.ays-quiz-container').first();
3302                    if( firstQuiz.find('input[name="ays_quiz_id"]').length > 0 ){
3303                        var fisrtQuizId = firstQuiz.find('input[name="ays_quiz_id"]').val();
3304                        var fisrtQuizOptions = JSON.parse(atob(window.aysQuizOptions[fisrtQuizId]));
3305
3306                        var questions_count = firstQuiz.find('div[data-question-id]').length;
3307
3308                        if(typeof fisrtQuizOptions.enable_autostart == 'undefined'){
3309                            fisrtQuizOptions.enable_autostart = 'off';
3310                        }
3311
3312                        if( fisrtQuizOptions.enable_autostart == 'on' ){
3313                            if ( questions_count > 0 ) {
3314                                setTimeout(function(){
3315                                    firstQuiz.find('.ays_next.start_button').trigger('click');
3316                                }, 500);
3317                            }
3318
3319                        }
3320                    }
3321                    clearInterval(ays_quiz_autostart_interval);
3322                }
3323            }, 500);
3324        }
3325
3326        $(document).find('.ays_next.start_button.ays_quiz_enable_loader').each(function(e){
3327            var $this = $(this);
3328            var container = $(this).parents('.ays-quiz-container');
3329
3330            var ays_quiz = setInterval( function() {
3331                if (document.readyState === 'complete') {
3332                    var startButtonText = quizLangObj.startButtonText;
3333                    if (startButtonText == null || startButtonText == '' ) {
3334                        startButtonText = quizLangObj.defaultStartButtonText;
3335                    }
3336
3337                    container.find('.ays_quiz_start_button_loader_container').addClass('ays_display_none');
3338                    if ( $this.hasClass('ays_quiz_enable_loader') ) {
3339                        $this.removeClass('ays_quiz_enable_loader');
3340                    }
3341                    $this.prop('disabled', false);
3342                    $this.val( startButtonText );
3343                    clearInterval(ays_quiz);
3344                }
3345            }, 500);
3346        });
3347
3348        $(document).find('.show_timer_countdown').each(function(e){
3349            // Countdown date
3350            var countDownEndDate = $(this).data('timer_countdown');
3351            var quiz_id = $(this).parents(".ays-quiz-container").attr("id");
3352            if (countDownEndDate != '' && countDownEndDate != undefined) {
3353                var showM = $(this).parents('.step').data('messageExist');
3354                ays_countdown_datetime(countDownEndDate, !showM, quiz_id);
3355            }
3356        });
3357
3358        function toggleFullscreen(elem) {
3359            elem = elem || document.documentElement;
3360            if (!document.fullscreenElement && !document.mozFullScreenElement &&
3361                !document.webkitFullscreenElement && !document.msFullscreenElement) {
3362                aysQuizFullScreenActivate( elem );
3363                if (elem.requestFullscreen) {
3364                    elem.requestFullscreen();
3365                }else if (elem.msRequestFullscreen) {
3366                    elem.msRequestFullscreen();
3367                }else if (elem.mozRequestFullScreen) {
3368                    elem.mozRequestFullScreen();
3369                }else if (elem.webkitRequestFullscreen) {
3370                    elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
3371                }
3372            }else{
3373                aysQuizFullScreenDeactivate( elem );
3374                if(document.exitFullscreen) {
3375                    document.exitFullscreen();
3376                }else if (document.msExitFullscreen) {
3377                    document.msExitFullscreen();
3378                }else if (document.mozCancelFullScreen) {
3379                    document.mozCancelFullScreen();
3380                }else if (document.webkitExitFullscreen) {
3381                    document.webkitExitFullscreen();
3382                }
3383            }
3384        }
3385
3386        function aysQuizFullScreenActivate( elem ){
3387            $(elem).find('.ays-quiz-full-screen-container > .ays-quiz-close-full-screen').css({'display':'block'});
3388            $(elem).find('.ays-quiz-full-screen-container > .ays-quiz-open-full-screen').css('display','none');
3389            //$(elem).find('.step:not(:first-of-type,.ays_thank_you_fs)').css({'height':'100vh'});
3390            $(elem).css({'overflow':'auto'});
3391
3392            if( $(elem).find('.ays_quiz_reports').length > 0 ){
3393                $(elem).find('.ays_quiz_reports').css({
3394                    'position': 'fixed',
3395                    'z-index': '1',
3396                });
3397            }else{
3398                if( $(elem).find('.ays_quiz_rete_avg').length > 0 ){
3399                    $(elem).find('.ays_quiz_rete_avg').css({
3400                        'position': 'fixed',
3401                        'z-index': '1',
3402                    });
3403                }
3404
3405                if( $(elem).find('.ays_quizn_ancnoxneri_qanak').length > 0 ){
3406                    $(elem).find('.ays_quizn_ancnoxneri_qanak').css({
3407                        'position': 'fixed',
3408                        'z-index': '1',
3409                    });
3410                }
3411            }
3412        }
3413
3414        function aysQuizFullScreenDeactivate( elem ){
3415            $(elem).find('.ays-quiz-full-screen-container > svg.ays-quiz-open-full-screen').css({'display':'block'});
3416            $(elem).find('.ays-quiz-full-screen-container > svg.ays-quiz-close-full-screen').css('display','none');
3417            //$(elem).find('.step:not(:first-of-type)').css({'height':'auto'});
3418            $(elem).css({'overflow':'initial'});
3419
3420            if( $(elem).find('.ays_quiz_reports').length > 0 ){
3421                $(elem).find('.ays_quiz_reports').css({
3422                    'position': 'absolute',
3423                    'z-index': '1',
3424                });
3425            }else{
3426                if( $(elem).find('.ays_quiz_rete_avg').length > 0 ){
3427                    $(elem).find('.ays_quiz_rete_avg').css({
3428                        'position': 'absolute',
3429                        'z-index': '1',
3430                    });
3431                }
3432
3433                if( $(elem).find('.ays_quizn_ancnoxneri_qanak').length > 0 ){
3434                    $(elem).find('.ays_quizn_ancnoxneri_qanak').css({
3435                        'position': 'absolute',
3436                        'z-index': '1',
3437                    });
3438                }
3439            }
3440        }
3441
3442        document.addEventListener('fullscreenchange', function(event) {
3443            if (!document.fullscreenElement) {
3444                var eventTarget = event.target
3445                if( $( eventTarget ).hasClass('ays-quiz-container') ){
3446                    aysQuizFullScreenDeactivate( eventTarget );
3447                }
3448            }
3449        }, false);
3450
3451        $(document).on('click', '.ays-quiz-open-full-screen, .ays-quiz-close-full-screen', function() {
3452            var quiz_container = $(this).parents('.ays-quiz-container').get(0);
3453            toggleFullscreen(quiz_container);
3454        });
3455
3456        $(document).on('click', '.action-button.ays_chain_next_quiz_button', function () {
3457            window.location.reload();
3458        });
3459
3460        $(document).on('click', '.action-button.ays_chain_see_result_button', function () {
3461            window.location.reload();
3462        });
3463    });
3464
3465    function show_hide_rows(page) {
3466
3467        var rows = jQuery('table.ays-add-questions-table tbody tr');
3468        rows.each(function (index) {
3469            jQuery(this).css('display', 'none');
3470        });
3471        var counter = page * 5 - 4;
3472        for (var i = counter; i < (counter + 5); i++) {
3473            rows.eq(i - 1).css('display', 'table-row');
3474        }
3475    }
3476
3477    function createPagination(pagination, pageShow) {
3478        // (pagination, pageShow)
3479        function aysPagination(baseElement, pageShow) {
3480            this.baseElement = baseElement;
3481            this.pageShow = pageShow
3482            this.pageNow = 1
3483            var pages = this.baseElement.parents('.ays-quiz-wrap').find('div[data-question-id]').length;
3484            var pageNum = 0;
3485            var pageOffset = 0;
3486
3487            this._initNav = function() {
3488                var _this = this;
3489                if( _this.baseElement.hasClass('ays-quiz-questions-nav-with-controls') ){
3490                    var pagePos = (this.baseElement.width()/2) - (parseInt(this.baseElement.find('.ays-quiz-questions-nav-item:first-child').css('width'))/2);
3491                    _this.baseElement.find('div.ays-quiz-questions-nav-content').css({
3492                        'margin-left': pagePos,
3493                    });
3494                }
3495
3496                //init events
3497                var toPage;
3498                _this.baseElement.on('click', '.ays-quiz-questions-nav-item a.ays_questions_nav_question', function (e) {
3499                    toPage = jQuery(this).parent().index();
3500                    _this._navPage(toPage);
3501                });
3502
3503                if( _this.baseElement.hasClass('ays-quiz-questions-nav-with-controls') ){
3504                    _this.baseElement.on('click', '.ays-quiz-questions-nav-go-left', function (e) {
3505                        _this._navScroll(_this.pageNow, 'left');
3506                    });
3507
3508                    _this.baseElement.on('click', '.ays-quiz-questions-nav-go-right', function (e) {
3509                        _this._navScroll(_this.pageNow, 'right');
3510                    });
3511                }
3512            }
3513
3514            this._navPage = function(toPage) {
3515                this.pageNow = toPage;
3516                var sel = jQuery('.ays-quiz-questions-nav-item', this.baseElement), w = sel.first().outerWidth()+10,
3517                    diff = toPage - pageNum;
3518
3519                if (toPage >= 0 && toPage <= pages - 1) {
3520                    sel.removeClass('ays-quiz-questions-nav-item-active').eq(toPage).addClass('ays-quiz-questions-nav-item-active');
3521                    this.baseElement.find('[disabled]').removeAttr('disabled');
3522                    sel.eq(toPage).attr('disabled', 'disabled');
3523                    sel.eq(toPage).find('a.ays_questions_nav_question').attr('disabled', 'disabled');
3524                    pageNum = toPage;
3525                } else {
3526                    return false;
3527                }
3528
3529                if (toPage <= (pages - (this.pageShow + (diff > 0 ? 0 : 1))) && toPage >= 0) {
3530                    pageOffset = pageOffset + -w * diff;
3531                } else {
3532                    pageOffset = (toPage > 0) ? -w * (pages - this.pageShow) : 0;
3533                }
3534
3535                if( this.baseElement.hasClass('ays-quiz-questions-nav-with-controls') ){
3536                    sel.parent().css('left', pageOffset + 'px');
3537                }
3538            }
3539
3540            this._navScroll = function(toPage, dir) {
3541
3542                if(dir == 'left'){
3543                    toPage -= 3;
3544                }
3545
3546                if(dir == 'right'){
3547                    toPage += 3;
3548                }
3549
3550                if(toPage > pages - 1){
3551                    toPage = pages - 1;
3552                }
3553
3554                if(toPage < 0){
3555                    toPage = 0;
3556                }
3557
3558                this.pageNow = toPage;
3559
3560                var sel = jQuery('.ays-quiz-questions-nav-item', this.baseElement),
3561                    w = sel.first().outerWidth()+10,
3562                    diff = toPage - pageNum;
3563
3564                if (toPage >= 0 && toPage <= pages - 1) {
3565                    pageNum = toPage;
3566                } else {
3567                    return false;
3568                }
3569
3570                if (toPage <= (pages - (this.pageShow + (diff > 0 ? 0 : 1))) && toPage >= 0) {
3571                    pageOffset = pageOffset + -w * diff;
3572                } else {
3573                    pageOffset = (toPage > 0) ? -w * (pages - this.pageShow) : 0;
3574                }
3575
3576                sel.parent().css('left', pageOffset + 'px');
3577            }
3578
3579            this._initNav();
3580
3581            return this;
3582        }
3583        var bullets = new aysPagination(pagination, pageShow);
3584        
3585        return bullets;
3586    }
3587
3588})( jQuery );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.