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 myOptions.quiz_enable_animation_top = myOptions.quiz_enable_animation_top ? myOptions.quiz_enable_animation_top : 'on'; 7 var EnableQuizAnimationTop = ( myOptions.quiz_enable_animation_top && myOptions.quiz_enable_animation_top == 'on' ) ? true : false; 8 if( EnableQuizAnimationTop ){ 9 $('html, body').animate({ 10 scrollTop: $(this).offset().top - QuizAnimationTop + 'px' 11 }, 'slow'); 12 } 13 return this; // for chaining... 14 } 15 if (!String.prototype.trim) { 16 (function() { 17 String.prototype.trim = function() { 18 return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); 19 }; 20 })(); 21 } 22 $(document).find('.for_quiz_rate_avg.ui.rating').rating('disable'); 23 24 var ays_quiz_container, ays_quiz_container_id; //flag to prevent quick multi-click glitches 25 var myOptions, myQuizOptions, explanationTimeout, aysTimerInterval; 26 var emailValivatePattern = /^[a-zA-Z0-9\._+-]+@[a-zA-Z0-9\._-]+\.\w{2,}$/; 27 28 if( typeof window.aysSeeResultConfirmBox == 'undefined' ){ 29 window.aysSeeResultConfirmBox = []; 30 } 31 32 if( typeof window.aysEarlyFinishConfirmBox == 'undefined' ){ 33 window.aysEarlyFinishConfirmBox = []; 34 } 35 36 window.countdownTimeForShowInterval = null; 37 window.aysTimerIntervalFlag = null; 38 39 function time_limit(e) { 40 var quizId = $(e.target).parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val(); 41 myOptions = JSON.parse(atob(window.aysQuizOptions[quizId])); 42 43 if(checkQuizPassword(e, myOptions, false) === false){ 44 return false; 45 } 46 47 if(typeof myOptions.answers_rw_texts == 'undefined'){ 48 myOptions.answers_rw_texts = 'on_passing'; 49 } 50 var quizOptionsName = 'quizOptions_'+quizId; 51 myQuizOptions = []; 52 if(typeof window[quizOptionsName] !== 'undefined'){ 53 for(var i in window[quizOptionsName]){ 54 if(window[quizOptionsName].hasOwnProperty(i)){ 55 myQuizOptions[i] = (JSON.parse(window.atob(window[quizOptionsName][i]))); 56 } 57 } 58 } 59 60 if(typeof window.aysSeeResultConfirmBox !== 'undefined'){ 61 window.aysSeeResultConfirmBox[ quizId ] = false; 62 } 63 64 if(typeof window.aysEarlyFinishConfirmBox !== 'undefined'){ 65 window.aysEarlyFinishConfirmBox[ quizId ] = false; 66 } 67 68 var container = $(e.target).parents('.ays-quiz-container'); 69 if ($(this).parents('.step').next().find('.information_form').length === 0 ){ 70 var quizMusic = container.find('.ays_quiz_music'); 71 if(quizMusic.length !== 0){ 72 var soundEls = $(document).find('.ays_music_sound'); 73 container.find('.ays_music_sound').removeClass('ays_display_none'); 74 if(!isPlaying(quizMusic.get(0))){ 75 container.find('.ays_quiz_music')[0].play(); 76 audioVolumeIn(container.find('.ays_quiz_music')[0]); 77 } 78 } 79 container.find('.ays-live-bar-wrap').css({'display': 'block'}); 80 container.find('.ays-live-bar-percent').css({'display': 'inline-block'}); 81 container.find('input.ays-start-date').val(GetFullDateTime()); 82 } 83 if ($(this).parents('.step').next().find('.information_form').length === 0 && myOptions.enable_timer == 'on') { 84 container.find('div.ays-quiz-timer').hide(800); 85 var timer = parseInt(container.find('div.ays-quiz-timer').attr('data-timer')); 86 var pageTitle = $(document).find('title'); 87 var pageTitleText = $(document).find('title').html(); 88 var timeForShow = ""; 89 90 // Display all questions on one page 91 myOptions.quiz_timer_red_warning = ( myOptions.quiz_timer_red_warning ) ? myOptions.quiz_timer_red_warning : 'off'; 92 var quiz_timer_red_warning = (myOptions.quiz_timer_red_warning && myOptions.quiz_timer_red_warning == "on") ? true : false;
93 94 if (!isNaN(timer) && myOptions.timer !== undefined) { 95 if (myOptions.timer === timer && timer !== 0) { 96 timer += 2; 97 if (timer !== undefined) { 98 var countDownDate = new Date().getTime() + (timer * 1000); 99 var timerFlag = false; 100 101 // Message before timer 102 var quiz_message_before_timer = (myOptions.quiz_message_before_timer && myOptions.quiz_message_before_timer != "") ? ( myOptions.quiz_message_before_timer ) : ''; 103 104 if ( quiz_message_before_timer != '' ) { 105 quiz_message_before_timer = quiz_message_before_timer.replace(/(["'])/g, "\\$1") + " "; 106 107 $(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>'); 108 } 109 110 aysTimerInterval = setInterval(function () { 111 var now = new Date().getTime(); 112 var distance = countDownDate - Math.ceil(now/1000)*1000; 113 var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); 114 var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); 115 var seconds = Math.floor((distance % (1000 * 60)) / 1000); 116 var sec = seconds; 117 var min = minutes; 118 var hour = hours; 119 if(hours <= 0){ 120 hours = null; 121 }else if (hours < 10) { 122 hours = '0' + hours; 123 } 124 if (minutes < 10) { 125 minutes = '0' + minutes; 126 } 127 if (seconds < 10) { 128 seconds = '0' + seconds; 129 } 130 timeForShow = ((hours==null)? "" : (hours + ":")) + minutes + ":" + seconds; 131 if(distance <=1000){ 132 timeForShow = ((hours==null) ? "" : "00:") + "00:00"; 133 container.find('div.ays-quiz-timer').html(timeForShow); 134 if(myOptions.quiz_timer_in_title == 'on'){ 135 pageTitle.html( timeForShow + " - " + pageTitleText ); 136 } 137 }else{ 138 container.find('div.ays-quiz-timer').html(timeForShow); 139 if(myOptions.quiz_timer_in_title == 'on'){ 140 pageTitle.html( timeForShow + " - " + pageTitleText ); 141 } 142 } 143 144 if ( quiz_timer_red_warning ) { 145 var distanceSec = Math.floor(distance / 1000); 146 var timerPercentage = Math.floor(( timer - distanceSec ) * 100); 147 var percentage = Math.floor( timerPercentage / timer ); 148 149 if ( percentage >= 90 && ! timerFlag ) { 150 var timerContainer = container.find('section.ays_quiz_timer_container'); 151 timerFlag = true; 152 153 if ( ! timerContainer.hasClass( 'ays_quiz_timer_red_warning' ) ) { 154 timerContainer.addClass( 'ays_quiz_timer_red_warning' ); 155 } 156 } 157 } 158 159 container.find('.ays_quiz_timer_container').show(); 160 container.find('div.ays-quiz-timer').show(500); 161 if(container.find('.ays-quiz-timer').length === 0){ 162 clearInterval(aysTimerInterval); 163 if(myOptions.quiz_timer_in_title == 'on'){ 164 pageTitle.html( pageTitleText ); 165 } 166 container.find('.ays_quiz_timer_container').slideUp(500); 167 } 168 169 if(container.find('.ays_finish.action-button').hasClass("ays_timer_end") ||
170 container.find('.ays_next.action-button').hasClass("ays_timer_end")){ 171 clearInterval(aysTimerInterval); 172 if(myOptions.quiz_timer_in_title == 'on'){ 173 pageTitle.html( pageTitleText ); 174 } 175 container.find('.ays_quiz_timer_container').slideUp(500); 176 } 177 178 if(hour == 0 && min == 0 && sec < 1){ 179 container.find('.ays_buttons_div > *:not(input.ays_finish)').off('click'); 180 } 181 182 if (distance <= 1) { 183 clearInterval(aysTimerInterval); 184 if(! container.find('div.ays-quiz-after-timer').hasClass('empty_after_timer_text')){ 185 container.find('.ays_quiz_timer_container').css({ 186 'position': 'static', 187 'height': '100%', 188 }); 189 container.find('div.ays-quiz-timer').slideUp(); 190 container.find('div.ays-quiz-after-timer').slideDown(500); 191 }else{ 192 container.find('.ays_quiz_timer_container').slideUp(500); 193 } 194 if(myOptions.quiz_timer_in_title == 'on'){ 195 pageTitle.html( pageTitleText ); 196 } 197 var totalSteps = container.find('div.step').length; 198 var currentStep = container.find('div.step.active-step'); 199 var thankYouStep = container.find('div.step.ays_thank_you_fs'); 200 var infoFormLast = thankYouStep.prev().find('div.information_form'); 201 if(infoFormLast.length == 0){ 202 if (currentStep.hasClass('ays_thank_you_fs') === false) { 203 var steps = totalSteps - 3; 204 container.find('div.step').each(function (index) { 205 if ($(this).hasClass('ays_thank_you_fs')) { 206 $(this).addClass('active-step') 207 }else{ 208 $(this).css('display', 'none'); 209 } 210 }); 211 window.aysTimerIntervalFlag = true; 212 213 var ays_finish_button = container.find('input.ays_finish'); 214 if(ays_finish_button.prop('disabled')){ 215 ays_finish_button.prop('disabled', false); 216 } 217 ays_finish_button.addClass('ays-quiz-after-timer-end'); 218 ays_finish_button.trigger('click'); 219 } 220 }else{ 221 currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').parent().slideUp(500); 222 container.find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut'); 223 container.find('.ays-live-bar-percent').removeClass('rubberBand').addClass('bounceOut'); 224 setTimeout(function () { 225 container.find('.ays-live-bar-wrap').css('display','none'); 226 container.find('.ays-live-bar-percent').css('display','none'); 227 },300); 228 229 container.find('div.step').each(function (index) { 230 $(this).css('display', 'none'); 231 $(this).removeClass('active-step') 232 }); 233 aysAnimateStep(ays_quiz_container.data('questEffect'), currentStep, infoFormLast.parent()); 234 // infoFormLast.parent().css('display', 'flex'); 235 infoFormLast.parent().addClass('active-step'); 236 } 237 } 238 }, 1000); 239 } 240 } else { 241 alert('Wanna cheat??'); 242 window.location.reload(); 243 } 244 } 245 246 }else{ 247 // $(this).parents('.step').next().find('.information_form').find('.ays_
247next').on('click', function () { 248 // if($(this).parents('.step').find('.information_form').find('.ays_next.action-button').hasClass('ays_start_allow')){ 249 // time_limit(e); 250 // } 251 // }); 252 } 253 } 254 255 $(document).on('click', '.ays_next.start_button', time_limit); 256 257 $(document).on('click', '.ays_next.start_button', function(e){ 258 259 if(checkQuizPassword(e, myOptions, false) === false){ 260 return false; 261 } 262 263 // Enable the Show/Hide toggle 264 myOptions.quiz_bg_img_during_the_quiz = (myOptions.quiz_bg_img_during_the_quiz) ? myOptions.quiz_bg_img_during_the_quiz : 'off'; 265 var quiz_bg_img_during_the_quiz =(myOptions.quiz_bg_img_during_the_quiz && myOptions.quiz_bg_img_during_the_quiz == 'on') ? true : false; 266 267 ays_quiz_container_id = $(this).parents(".ays-quiz-container").attr("id"); 268 ays_quiz_container = $('#'+ays_quiz_container_id); 269 aysResetQuiz( ays_quiz_container ); 270 271 $(this).parents('div.step').removeClass('active-step'); 272 $(this).parents('div.step').next().addClass('active-step'); 273 274 if (typeof $(this).attr("data-enable-leave-page") !== 'undefined') { 275 $(this).attr("data-enable-leave-page",true); 276 } 277 ays_quiz_container.css('padding-bottom', '0px'); 278 var ancnoxneriQanak = $(this).parents('.ays-questions-container').find('.ays_quizn_ancnoxneri_qanak'); 279 var aysQuizReteAvg = $(this).parents('.ays-questions-container').find('.ays_quiz_rete_avg'); 280 281 if( ays_quiz_container.find('.enable_min_selection_number').length > 0 ){ 282 ays_quiz_container.find('.enable_min_selection_number').each(function(){ 283 var thisStep = $(this).parents('.step'); 284 thisStep.find('input.ays_next').attr('disabled', 'disabled'); 285 thisStep.find('i.ays_next_arrow').attr('disabled', 'disabled'); 286 287 thisStep.find('input.ays_early_finish').attr('disabled', 'disabled'); 288 thisStep.find('i.ays_early_finish').attr('disabled', 'disabled'); 289 }); 290 } 291 292 setTimeout(function(){ 293 ays_quiz_container.css('border-radius', myOptions.quiz_border_radius + 'px'); 294 ays_quiz_container.find('.step').css('border-radius', myOptions.quiz_border_radius + 'px'); 295 }, 400); 296 297 ays_quiz_container.find('iframe').removeAttr('style').css({ 298 width: '100%' 299 }); 300 aysAnimateStep(ays_quiz_container.data('questEffect'), aysQuizReteAvg); 301 aysAnimateStep(ays_quiz_container.data('questEffect'), ancnoxneriQanak); 302 303 if ($(this).parents('.step').next().find('.information_form').length === 0 ){ 304 var questions_count = $(this).parents('form').find('div[data-question-id]').length; 305 var curent_number = $(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]')) + 1; 306 var next_sibilings_count = $(this).parents('form').find('.ays_question_count_per_page').val(); 307 if(parseInt(next_sibilings_count) > 0 && 308 ($(this).parents('.step').attr('data-question-id') || 309 $(this).parents('.step').next().attr('data-question-id'))){ 310 var final_width = ((parseInt(next_sibilings_count)) / questions_count * 100) + "%"; 311 if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ 312 $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(parseInt(next_sibilings_count))); 313 }else{ 314 $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width)); 315 } 316 $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000); 317 }else{ 318 var final_width = ((curent_number+1) / questions_count * 100) + "%"; 319 if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ 320 $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+1)); 321 }else{ 322 $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width)); 323 } 324 $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000); 325 } 326 } 327 328 if ( ays_quiz_container.hasClass('ays_quiz_hide_bg_on_start_page') ) { 329 ays_quiz_container.removeClass('ays_quiz_hide_bg_on_start_page'); 330 } 331 332 if( quiz_bg_img_during_the_quiz ){ 333 if ( !ays_quiz_container.hasClass('ays_quiz_hide_bg_during_quiz') ) { 334 ays_quiz_container.addClass('ays_quiz_hide_bg_during_quiz'); 335 } 336 } 337 }); 338 339 $(document).on('focus', '.ays-quiz-container input', function () { 340 $(window).on('keydown', function (event) { 341 var _this = $(event.target); 342 var submitFlag = true; 343 var quizLoginForm = $(event.target).parents('.ays_quiz_login_form'); 344 if( quizLoginForm.length > 0 ){ 345 submitFlag = false;
346 } 347 if (event.keyCode === 13) { 348 if( submitFlag ){ 349 return false; 350 } 351 } 352 }); 353 }); 354 355 $(document).on('blur', '.ays-quiz-container input', function () { 356 $(window).off('keydown'); 357 }); 358 359 $.each($(document).find('.ays_block_content'), function () { 360 if ($(document).find('.ays_block_content').length != 0) { 361 var ays_block_element = $(this).parents().eq(2); 362 ays_block_element.find('input.ays-start-date').val(GetFullDateTime()); 363 ays_block_element.find('div.ays-quiz-timer').slideUp(500); 364 var timer = parseInt(ays_block_element.find('div.ays-quiz-timer').attr('data-timer')); 365 var timerInTitle = ays_block_element.find('div.ays-quiz-timer').data('showInTitle'); 366 var tabTitle = document.title; 367 setTimeout(function(){ 368 if (timer !== NaN) { 369 timer += 2; 370 if (timer !== undefined) { 371 var countDownDate = new Date().getTime() + (timer * 1000); 372 var x = setInterval(function () { 373 var now = new Date().getTime(); 374 var distance = countDownDate - Math.ceil(now/1000)*1000; 375 var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); 376 var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); 377 var seconds = Math.floor((distance % (1000 * 60)) / 1000); 378 var timeForShow = ""; 379 if(hours <= 0){ 380 hours = null; 381 }else if (hours < 10) { 382 hours = '0' + hours; 383 } 384 if (minutes < 10) { 385 minutes = '0' + minutes; 386 } 387 if (seconds < 10) { 388 seconds = '0' + seconds; 389 } 390 timeForShow = ((hours==null)? "" : (hours + ":")) + minutes + ":" + seconds; 391 if(distance <=1000){ 392 timeForShow = ((hours==null) ? "" : "00:") + "00:00"; 393 ays_block_element.find('div.ays-quiz-timer').html(timeForShow); 394 if(timerInTitle){ 395 document.title = timeForShow + " - " + tabTitle ; 396 } 397 }else{ 398 ays_block_element.find('div.ays-quiz-timer').html(timeForShow); 399 if(timerInTitle){ 400 document.title = timeForShow + " - " + tabTitle ; 401 } 402 } 403 ays_block_element.find('div.ays-quiz-timer').slideDown(500); 404 var ays_block_element_redirect_url = ays_block_element.find('.ays_redirect_url').text(); 405 if (distance <= 1) { 406 clearInterval(x); 407 var totalSteps = ays_block_element.find('div.step').length; 408 var currentStep = ays_block_element.eq(2).find('div.step.active-step'); 409 var currentStepIndex = ays_block_element.eq(2).find('div.step.active-step').index(); 410 if (currentStep.hasClass('ays_thank_you_fs') === false) { 411 var steps = totalSteps - 3; 412 ays_block_element.find('div.step').each(function (index) { 413 if (index >= (currentStepIndex - 1) && index <= steps) { 414 $(this).remove(); 415 } 416 }); 417 window.location = ays_block_element_redirect_url; 418 } 419 } 420 }, 1000); 421 } 422 } 423 }, 1000); 424 } 425 }); 426 427 // Old check function 428 // $(document).find('button.ays_check_answer').on('click', function (e) { 429 // var thisAnswerOptions; 430 // var quizContainer = $(e.target).parents('.ays-quiz-container'); 431 // var right_answer_sound = quizContainer.find('.ays_quiz_right_ans_sound').get(0); 432 // var wrong_answer_sound = quizContainer.find('.ays_quiz_wrong_ans_sound').get(0); 433 // var questionId = $(this).parents('.step').data('questionId'); 434 // var finishAfterWrongAnswer = (myOptions.finish_after_wrong_answer && myOptions.finish_after_wrong_answer == "on") ? true : false;
435 // thisAnswerOptions = myQuizOptions[questionId]; 436 // if($(this).parent().find('.ays-text-input').val() !== ""){ 437 // if ($(e.target).parents('form[id^="ays_finish_quiz"]').hasClass('enable_correction')) { 438 // if($(e.target).parents('.step').hasClass('not_influence_to_score')){ 439 // return false; 440 // } 441 // $(this).css({ 442 // animation: "bounceOut .5s", 443 // }); 444 // setTimeout(function(){ 445 // $(e.target).parent().find('.ays-text-input').css('width', '100%'); 446 // $(e.target).css("display", "none"); 447 // },480); 448 // $(e.target).parent().find('.ays-text-input').css('background-color', '#eee'); 449 // $(this).parent().find('.ays-text-input').attr('disabled', 'disabled'); 450 // $(this).attr('disabled', 'disabled'); 451 // $(this).off('change'); 452 // $(this).off('click'); 453 // $(this).parents('.ays-field').addClass('ays-answered-text-input'); 454 // var input = $(this).parent().find('.ays-text-input'); 455 // var type = input.attr('type'); 456 // var userAnsweredText = input.val().trim(); 457 458 // // Enable case sensitive text 459 // var enable_case_sensitive_text = (thisAnswerOptions.enable_case_sensitive_text && thisAnswerOptions.enable_case_sensitive_text != "") ? thisAnswerOptions.enable_case_sensitive_text : false; 460 461 // var trueAnswered = false; 462 // var thisQuestionAnswer = thisAnswerOptions.question_answer.toLowerCase(); 463 // var displayingQuestionAnswer = thisAnswerOptions.question_answer; 464 465 // if( type == 'text' || type == 'short_text' ){ 466 // if ( enable_case_sensitive_text ) { 467 // thisQuestionAnswer = thisAnswerOptions.question_answer; 468 // } 469 // } 470 471 // if(type == 'date'){ 472 // var correctDate = new Date(thisAnswerOptions.question_answer), 473 // correctDateYear = correctDate.getFullYear(), 474 // correctDateMonth = correctDate.getMonth(), 475 // correctDateDay = correctDate.getDate(); 476 // var userDate = new Date(userAnsweredText), 477 // userDateYear = userDate.getFullYear(), 478 // userDateMonth = userDate.getMonth(), 479 // userDateDay = userDate.getDate(); 480 // if(correctDateYear == userDateYear && correctDateMonth == userDateMonth && correctDateDay == userDateDay){ 481 // trueAnswered = true; 482 // } 483 // }else if(type != 'number'){ 484 // thisQuestionAnswer = thisQuestionAnswer.split('%%%'); 485 // displayingQuestionAnswer = displayingQuestionAnswer.split('%%%'); 486 // for(var i = 0; i < thisQuestionAnswer.length; i++){ 487 // if ( enable_case_sensitive_text ) { 488 // if(userAnsweredText == thisQuestionAnswer[i].trim()){ 489 // trueAnswered = true; 490 // break; 491 // } 492 // } else { 493 // if(userAnsweredText.toLowerCase() == thisQuestionAnswer[i].trim()){ 494 // trueAnswered = true; 495 // break; 496 // } 497 // } 498 // } 499 // }else{ 500 // if(type == 'number'){ 501 // if(userAnsweredText.toLowerCase().replace(/\.([^0]+)0+$/,".$1") == thisQuestionAnswer.trim().replace(/\.([^0]+)0+$/,".$1")){ 502 // trueAnswered = true; 503 // } 504 // } else { 505 // if(userAnsweredText.toLowerCase() == thisQuestionAnswer.trim()){ 506 // trueAnswered = true; 507 // } 508 // } 509 // } 510 511 // if(trueAnswered){ 512 // if((right_answer_sound)){ 513 // resetPlaying([right_answer_sound, wrong_answer_sound]); 514 // setTimeout(function(){ 515 // right_answer_sound.play(); 516 // }, 10); 517 // } 518 // $(this).parent().find('.ays-text-input').css('background-color', 'rgba(39,174,96,0.5)'); 519 // $(this).parent().find('input[name="ays_answer_
519correct[]"]').val(1); 520 // if(! $(this).parents('.step').hasClass('not_influence_to_score')){ 521 // $(this).parents('.step').find('.right_answer_text').slideDown(250); 522 // } 523 // }else{ 524 // if((wrong_answer_sound)){ 525 // resetPlaying([right_answer_sound, wrong_answer_sound]); 526 // setTimeout(function(){ 527 // wrong_answer_sound.play(); 528 // }, 10); 529 // } 530 // $(this).parent().find('.ays-text-input').css('background-color', 'rgba(243,134,129,0.8)'); 531 // $(this).parent().find('input[name="ays_answer_correct[]"]').val(0); 532 // var rightAnswerText = '<div class="ays-text-right-answer">'; 533 534 // if(type == 'date'){ 535 // var correctDate = new Date(thisAnswerOptions.question_answer), 536 // correctDateYear = correctDate.getUTCFullYear(), 537 // correctDateMonth = (correctDate.getUTCMonth() + 1) < 10 ? "0"+(correctDate.getUTCMonth() + 1) : (correctDate.getUTCMonth() + 1), 538 // correctDateDay = (correctDate.getUTCDate() < 10) ? "0"+correctDate.getUTCDate() : correctDate.getUTCDate(); 539 // rightAnswerText += [correctDateMonth, correctDateDay, correctDateYear].join('/'); 540 // }else if(type != 'number'){ 541 // // rightAnswerText += thisQuestionAnswer[0]; 542 // rightAnswerText += displayingQuestionAnswer[0]; 543 // }else{ 544 // // rightAnswerText += thisQuestionAnswer; 545 // rightAnswerText += displayingQuestionAnswer; 546 // } 547 548 // rightAnswerText += '</div>'; 549 // $(this).parents('.ays-quiz-answers').append(rightAnswerText); 550 // $(this).parents('.ays-quiz-answers').find('.ays-text-right-answer').slideDown(500); 551 // if(! $(this).parents('.step').hasClass('not_influence_to_score')){ 552 // $(this).parents('.step').find('.wrong_answer_text').slideDown(250); 553 // } 554 // if(finishAfterWrongAnswer){ 555 // goToLastPage(e); 556 // } 557 // } 558 // var showExplanationOn = (myOptions.show_questions_explanation && myOptions.show_questions_explanation != "") ? myOptions.show_questions_explanation : "on_results_page"; 559 // if(showExplanationOn == 'on_passing' || showExplanationOn == 'on_both'){ 560 // if(! $(this).parents('.step').hasClass('not_influence_to_score')){ 561 // $(this).parents('.step').find('.ays_questtion_explanation').slideDown(250); 562 // } 563 // } 564 // } 565 // } 566 // }); 567 568 $(document).on('keyup keypress', 'textarea.ays_question_limit_length, input.ays_question_limit_length', function(e) { 569 var $this = $(this); 570 var questionId = $this.attr('data-question-id'); 571 var container = $this.parents('.ays-field').next('.ays_quiz_question_text_conteiner'); 572 var box = container.find('.ays_quiz_question_text_message'); 573 var questionTextMessage = container.find('.ays_quiz_question_text_message_span'); 574 575 if (questionId !== null && questionId != '') { 576 577 // Maximum length of a text field 578 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; 579 580 // Length 581 var question_text_max_length = (myQuizOptions[questionId].question_text_max_length && myQuizOptions[questionId].question_text_max_length != "") ? parseInt(myQuizOptions[questionId].question_text_max_length) : ''; 582 583 // Limit by 584 var question_limit_text_type = (myQuizOptions[questionId].question_limit_text_type && myQuizOptions[questionId].question_limit_text_type != "") ? myQuizOptions[questionId].question_limit_text_type : 'characters'; 585 586 // Show word/character counter 587 var question_enable_text_message = (myQuizOptions[questionId].question_enable_text_message && myQuizOptions[questionId].question_enable_text_message != '') ? myQuizOptions[questionId].question_enable_text_message : false;
588 589 var remainder = ''; 590 if(question_text_max_length != '' && question_text_max_length != 0){ 591 switch ( question_limit_text_type ) { 592 case 'characters': 593 var tval = $this.val(); 594 var tlength = tval.length; 595 var set = question_text_max_length; 596 var remain = parseInt(set - tlength); 597 if (remain <= 0 && e.which !== 0 && e.charCode !== 0) { 598 $this.val((tval).substring(0, tlength - 1)); 599 } 600 if (e.type=="keyup") { 601 var tval = $this.val().trim(); 602 if(tval.length > 0 && tval != null){ 603 var wordsLength = this.value.split('').length; 604 if (wordsLength > question_text_max_length) { 605 var trimmed = tval.split('', question_text_max_length).join(""); 606 $this.val(trimmed); 607 } 608 } 609 } 610 remainder = remain; 611 break; 612 case 'words': 613 if (e.type=="keyup") { 614 var tval = $this.val().trim(); 615 if(tval.length > 0 && tval != null){ 616 var wordsLength = this.value.match(/\S+/g).length; 617 if (wordsLength > question_text_max_length) { 618 var trimmed = tval.split(/\s+/, question_text_max_length).join(" "); 619 $this.val(trimmed + " "); 620 } 621 remainder = question_text_max_length - wordsLength; 622 } 623 } 624 break; 625 default: 626 break; 627 } 628 if (e.type=="keyup") { 629 if ( question_enable_text_message ) { 630 if(question_text_max_length != '' && question_text_max_length != 0){ 631 if (remainder <= 0) { 632 remainder = 0; 633 if (! box.hasClass('ays_quiz_question_text_error_message') ) { 634 box.addClass('ays_quiz_question_text_error_message') 635 } 636 }else{ 637 if ( box.hasClass('ays_quiz_question_text_error_message') ) { 638 box.removeClass('ays_quiz_question_text_error_message') 639 } 640 } 641 if (tval.length == 0 || tval == null) { 642 if ( box.hasClass('ays_quiz_question_text_error_message') ) { 643 box.removeClass('ays_quiz_question_text_error_message') 644 } 645 remainder = question_text_max_length; 646 } 647 648 questionTextMessage.html( remainder ); 649 } 650 } 651 } 652 } 653 } 654 }); 655 656 $(document).on('click', '.enable_max_selection_number input[type="checkbox"]', function(e) { 657 var $this = $(this); 658 659 var parent = $this.parents('.step'); 660 var questionId = parent.attr('data-question-id'); 661 questionId = parseInt( questionId ); 662 663 var checkedCount = parent.find('.ays-field input[type="checkbox"]:checked').length; 664 665 if (questionId !== null && questionId != '' && typeof myQuizOptions[questionId] != 'undefined') { 666 667 // Maximum length of a text field 668 var enable_max_selection_number = (myQuizOptions[questionId].enable_max_selection_number && myQuizOptions[questionId].enable_max_selection_number != "") ? myQuizOptions[questionId].enable_max_selection_number : false;
669 670 // Length 671 var max_selection_number = (myQuizOptions[questionId].max_selection_number && myQuizOptions[questionId].max_selection_number != "") ? parseInt(myQuizOptions[questionId].max_selection_number) : ''; 672 673 if( enable_max_selection_number === true && max_selection_number != '' ){ 674 675 if( max_selection_number < checkedCount ){ 676 return false; 677 } 678 } 679 } 680 681 }); 682 683 $(document).on('click', '.enable_min_selection_number input[type="checkbox"]', function(e) { 684 var $this = $(this); 685 var this_current_fs = $this.parents('.step[data-question-id]'); 686 var enableArrows = $this.parents(".ays-questions-container").find(".ays_qm_enable_arrows").val(); 687 var questions = $(this).parents('form').find('.step[data-question-id]'); 688 var next_sibilings_count = $(this).parents('form').find('.ays_question_count_per_page').val(); 689 var current_fs_indexes = []; 690 691 var thisIndex = 0; 692 for( var j = 0; j < Math.floor( questions.length / parseInt( next_sibilings_count ) ); j++ ){ 693 thisIndex += parseInt( next_sibilings_count ); 694 current_fs_indexes.push( thisIndex - 1 ); 695 } 696 697 var thisStepIndex = 0; 698 var thisQuestionStepIndex = questions.index( $this.parents('.step[data-question-id]') ); 699 for( var k = 0; k < current_fs_indexes.length; k++ ){ 700 if( thisQuestionStepIndex <= current_fs_indexes[k] ){ 701 thisStepIndex = current_fs_indexes[k]; 702 break; 703 } 704 } 705 706 if( thisStepIndex == 0 ){ 707 thisStepIndex = questions.length - 1; 708 } 709 710 var current_fs_index = questions.index( questions.eq( thisStepIndex ) ); 711 712 // Display all questions on one page 713 myOptions.quiz_display_all_questions = ( myOptions.quiz_display_all_questions ) ? myOptions.quiz_display_all_questions : 'off'; 714 var quiz_display_all_questions = (myOptions.quiz_display_all_questions && myOptions.quiz_display_all_questions == "on") ? true : false; 715 716 if ( quiz_display_all_questions ) { 717 next_sibilings_count = questions.length; 718 } 719 720 721 var buttonsDiv = $(this).parents('form').find('.step[data-question-id]').eq( thisStepIndex ).find('.ays_buttons_div'); 722 if($(this).parents('.step').attr('data-question-id')){ 723 if( parseInt( next_sibilings_count ) > 0 && ( $(this).parents('.step').attr('data-question-id') || $(this).parents('.step').next().attr('data-question-id') ) ){ 724 var sliceStart = current_fs_index - parseInt( next_sibilings_count ) < 0 ? 0 : current_fs_index - parseInt( next_sibilings_count ) + 1; 725 // this_current_fs = questions.slice( sliceStart, current_fs_index + 1 ); 726 this_current_fs = $(this).parents('.step[data-question-id]'); 727 }else{ 728 this_current_fs = $(this).parents('.step[data-question-id]'); 729 buttonsDiv = this_current_fs.find('.ays_buttons_div'); 730 } 731 }else{ 732 this_current_fs = $(this).parents('.step[data-question-id]'); 733 buttonsDiv = this_current_fs.find('.ays_buttons_div'); 734 } 735 736 this_current_fs.each(function(){ 737 var checkedMinSelCount = aysCheckMinimumCountCheckbox( $(this), myQuizOptions ); 738 // if( ays_quiz_is_question_min_count( $(this), !checkedMinSelCount ) === true ){ 739 if( checkedMinSelCount == true ){ 740 if(enableArrows){ 741 buttonsDiv.find('i.ays_next_arrow').removeAttr('disabled'); 742 buttonsDiv.find('i.ays_next_arrow').prop('disabled', false); 743 buttonsDiv.find('i.ays_early_finish').prop('disabled', false); 744 }else{ 745 buttonsDiv.find('input.ays_next').removeAttr('disabled'); 746 buttonsDiv.find('input.ays_next').prop('disabled', false); 747 buttonsDiv.find('input.ays_early_finish').prop('disabled', false); 748 } 749 }else{ 750 if(enableArrows){ 751 buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled'); 752 buttonsDiv.find('i.ays_next_arrow').prop('disabled', true); 753 buttonsDiv.find('i.ays_early_finish').prop('disabled', true); 754 }else{ 755 buttonsDiv.find('input.ays_next').attr('disabled', 'disabled'); 756 buttonsDiv.find('input.ays_next').prop('disabled', true); 757 buttonsDiv.find('input.ays_early_finish').prop('disabled', true); 758 } 759 } 760 // }else{ 761 // if(enableArrows){ 762 // buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled'); 763 // buttonsDiv.find('i.ays_next_arrow').prop('disabled', true); 764 // }else{ 765 // buttonsDiv.find('input.ays_next').attr('disabled', 'disabled'); 766 // buttonsDiv.find('input.ays_next').prop('disabled', true); 767 // return false;
768 // } 769 // } 770 }); 771 }); 772 773 $(document).on('keyup keypress', 'input.ays_question_number_limit_length', function(e) { 774 var $this = $(this); 775 var questionId = $this.attr('data-question-id'); 776 var parent = $this.parents('.ays-abs-fs'); 777 778 if (questionId !== null && questionId != '') { 779 var questionOptions = myQuizOptions[questionId]; 780 781 // Maximum length of a number field 782 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; 783 784 // Length 785 var question_number_max_length = (typeof questionOptions.question_number_max_length != 'undefined' && questionOptions.question_number_max_length !== "") ? parseInt(questionOptions.question_number_max_length) : ''; 786 787 // Minimum length of a number field 788 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; 789 790 // Length 791 var question_number_min_length = (typeof questionOptions.question_number_min_length != 'undefined' && questionOptions.question_number_min_length !== "") ? parseInt(questionOptions.question_number_min_length) : ''; 792 793 // Show error message 794 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; 795 796 // Message 797 var question_number_error_message = (questionOptions.question_number_error_message && questionOptions.question_number_error_message != "") ? questionOptions.question_number_error_message : ''; 798 799 800 if ( enable_question_number_max_length ) { 801 if(question_number_max_length !== ''){ 802 var tval = $this.val().trim(); 803 var inputVal = parseInt( tval ); 804 if( ! isNaN(inputVal) ){ 805 if ( inputVal > question_number_max_length ) { 806 $this.val(question_number_max_length); 807 } 808 809 if (e.type=="keyup") { 810 if ( inputVal > question_number_max_length ) { 811 $this.val(question_number_max_length); 812 } 813 } 814 } 815 } 816 } 817 818 if ( enable_question_number_min_length ) { 819 if(question_number_min_length !== ''){ 820 var tval = $this.val().trim(); 821 var inputVal = parseInt( tval ); 822 if( ! isNaN(inputVal) ){ 823 if ( inputVal < question_number_min_length ) { 824 $this.val(question_number_min_length); 825 } 826 827 if (e.type=="keyup") { 828 if ( inputVal < question_number_min_length ) { 829 $this.val(question_number_min_length); 830 } 831 } 832 } 833 } 834 } 835 836 if ( enable_question_number_error_message ) { 837 if ( question_number_error_message != "" ) { 838 var tval = $this.val().trim(); 839 var inputVal = tval; 840 841 var errorMessageBox = parent.find('.ays-quiz-number-error-message'); 842 843 if ( tval != "" ) { 844 845 if ( isNaN( +inputVal ) ) { 846 if ( errorMessageBox.hasClass('ays_display_none') ) { 847 errorMessageBox.removeClass('ays_display_none'); 848 } 849 } else if ( tval.indexOf("e") > -1 ) { 850 if ( errorMessageBox.hasClass('ays_display_none') ) { 851 errorMessageBox.removeClass('ays_display_none'); 852 } 853 } else if ( tval.slice(-1) == "e" ) { 854 if ( errorMessageBox.hasClass('ays_display_none') ) { 855 errorMessageBox.removeClass('ays_display_none'); 856 } 857 } else { 858 if ( ! errorMessageBox.hasClass('ays_display_none') ) { 859 errorMessageBox.addClass('ays_display_none'); 860 } 861 } 862 } else { 863 if ( ! errorMessageBox.hasClass('ays_display_none') ) { 864 errorMessageBox.addClass('ays_display_none'); 865 } 866 } 867 } 868 } 869 } 870 }); 871 872 // $(document).on('change', 'input[name^="ays_questions"]', function (e) { 873 874 // var _this = $(this); 875 // var parentStep = _this.parents('.step'); 876 // var questionID = parentStep.data('questionId'); 877 // var questionType = parentStep.attr('data-type'); 878 // var answerId = _this.val(); 879 880 // var quizContainer = $(e.target).parents('.ays-quiz-container'); 881 // var quizForm = quizContainer.find('form.ays-quiz-form'); 882 // var quizId = _this.parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val(); 883 884 // if( typeof questionID != "undefined" && questionID !== null && quizForm.hasClass('enable_correction') ){ 885 886 // var thisQuestionCorrectAnswer = new Array(); 887 // if (myQuizOptions[questionID] && typeof myQuizOptions[questionID].question_answer !== "undefined") { 888 // thisQuestionCorrectAnswer = myQuizOptions[questionID].question_answer.length <= 0 ? new Array() : myQuizOptions[questionID].question_answer; 889 // } 890 891 // var ifCorrectAnswer = thisQuestionCorrectAnswer[answerId] == '' ? '' : thisQuestionCorrectAnswer[answerId]; 892 // if( typeof ifCorrectAnswer != "undefined" ){ 893 // _this.parents('.ays-field').find('input[name="ays_answer_
893correct[]"]').val(ifCorrectAnswer); 894 895 // if( ifCorrectAnswer == '0' && questionType === 'radio' && $(e.target).parents('form.ays-quiz-form').hasClass('enable_correction') ){ 896 897 // for (var question_answer_ID in thisQuestionCorrectAnswer) { 898 // var UserAnswered_true_or_false = thisQuestionCorrectAnswer[question_answer_ID]; 899 // parentStep.find('.ays-quiz-answers .ays-field input[value="'+ question_answer_ID +'"]').prev().val(UserAnswered_true_or_false); 900 // } 901 // } 902 // } 903 // } 904 905 // if($(e.target).parents('.step').hasClass('not_influence_to_score')){ 906 // if($(e.target).attr('type') === 'radio') { 907 // $(e.target).parents('.ays-quiz-answers').find('.checked_answer_div').removeClass('checked_answer_div'); 908 // $(e.target).parents('.ays-field').addClass('checked_answer_div'); 909 // } 910 // if($(e.target).attr('type') === 'checkbox') { 911 // if(!$(e.target).parents('.ays-field').hasClass('checked_answer_div')){ 912 // $(e.target).parents('.ays-field').addClass('checked_answer_div'); 913 // }else{ 914 // $(e.target).parents('.ays-field').removeClass('checked_answer_div'); 915 // } 916 // } 917 // var checked_inputs = $(e.target).parents().eq(1).find('input:checked'); 918 // 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')) { 919 // if (checked_inputs.attr('type') === 'radio') { 920 // checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click'); 921 // } 922 // } 923 // return false; 924 // } 925 // if ($(e.target).parents().eq(4).hasClass('enable_correction')) { 926 // var right_answer_sound = quizContainer.find('.ays_quiz_right_ans_sound').get(0); 927 // var wrong_answer_sound = quizContainer.find('.ays_quiz_wrong_ans_sound').get(0); 928 // var finishAfterWrongAnswer = (myOptions.finish_after_wrong_answer && myOptions.finish_after_wrong_answer == "on") ? true : false; 929 // var showExplanationOn = (myOptions.show_questions_explanation && myOptions.show_questions_explanation != "") ? myOptions.show_questions_explanation : "on_results_page"; 930 // var explanationTime = myOptions.explanation_time && myOptions.explanation_time != "" ? parseInt(myOptions.explanation_time) : 4; 931 932 // myOptions.quiz_waiting_time = ( myOptions.quiz_waiting_time ) ? myOptions.quiz_waiting_time : "off"; 933 // var quizWaitingTime = (myOptions.quiz_waiting_time && myOptions.quiz_waiting_time == "on") ? true : false; 934 935 // myOptions.enable_next_button = ( myOptions.enable_next_button ) ? myOptions.enable_next_button : "off"; 936 // var quizNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == "on") ? true : false; 937 938 // if ( quizWaitingTime && !quizNextButton ) { 939 // explanationTime += 2; 940 // } 941 942 // var quizWaitingCountDownDate = new Date().getTime() + (explanationTime * 1000); 943 944 // if ($(e.target).parents().eq(1).find('input[name="ays_answer_correct[]"]').length !== 0) { 945 // var checked_inputs = $(e.target).parents().eq(1).find('input:checked'); 946 // if (checked_inputs.attr('type') === "radio") { 947 // checked_inputs.next().addClass('answered'); 948 // (checked_inputs.prev().val() == 1) ? checked_inputs.next().addClass('correct') : checked_inputs.next().addClass('wrong'); 949 // if (checked_inputs.prev().val() == 1) { 950 // $(e.target).parents('.ays-field').addClass('correct_div checked_answer_div'); 951 // $(e.target).next('label').addClass('correct answered'); 952 953 // if(myOptions.answers_rw_texts && (myOptions.answers_rw_texts == 'on_passing' || myOptions.answers_rw_texts == 'on_both' || myOptions.answers_rw_texts == 'disable' || myOptions.answers_rw_texts == 'on_results_page')){ 954 // if( myOptions.answers_rw_texts != 'on_results_page' ){ 955 // if(! $(e.target).parents('.step').hasClass('not_influence_to_score')){ 956 // $(e.target).parents().eq(3).find('.right_answer_text').slideDown(250); 957 // } 958 // } 959 // explanationTimeout = setTimeout(function(){ 960 // 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')) { 961 // checked_inputs.parents('div[data-question-id]').find('.ays_
961next').trigger('click'); 962 // } 963 // }, explanationTime*1000); 964 // if (quizWaitingTime && !quizNextButton) { 965 // window.countdownTimeForShowInterval = setInterval(function () { 966 // countdownTimeForShow( parentStep, quizWaitingCountDownDate ); 967 // }, 1000); 968 // } 969 // }else{ 970 // 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')) { 971 // checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click'); 972 // } 973 // } 974 // if((right_answer_sound)){ 975 // resetPlaying([right_answer_sound, wrong_answer_sound]); 976 // setTimeout(function(){ 977 // right_answer_sound.play(); 978 // }, 10); 979 // } 980 // } 981 // else { 982 // $(e.target).parents('.ays-quiz-answers').find('input[name="ays_answer_correct[]"][value="1"]').parent().addClass('correct_div checked_answer_div'); 983 // $(e.target).parents('.ays-quiz-answers').find('input[name="ays_answer_correct[]"][value="1"]').next().next().addClass('correct answered'); 984 // $(e.target).parents('.ays-field').addClass('wrong_div'); 985 986 // if(myOptions.answers_rw_texts && (myOptions.answers_rw_texts == 'on_passing' || myOptions.answers_rw_texts == 'on_both' || myOptions.answers_rw_texts == 'disable' || myOptions.answers_rw_texts == 'on_results_page')){ 987 // if( myOptions.answers_rw_texts != 'on_results_page' ){ 988 // if(! $(e.target).parents('.step').hasClass('not_influence_to_score')){ 989 // $(e.target).parents().eq(3).find('.wrong_answer_text').slideDown(250); 990 // } 991 // } 992 // explanationTimeout = setTimeout(function(){ 993 // if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && 994 // checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) { 995 // if(finishAfterWrongAnswer){ 996 // goToLastPage(e); 997 // }else{ 998 // checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click'); 999 // } 1000 // }else{ 1001 // if(finishAfterWrongAnswer){ 1002 // goToLastPage(e); 1003 // } 1004 // } 1005 // }, explanationTime * 1000); 1006 // if (quizWaitingTime && !quizNextButton) { 1007 // window.countdownTimeForShowInterval = setInterval(function () { 1008 // countdownTimeForShow( parentStep, quizWaitingCountDownDate ); 1009 // }, 1000); 1010 // } 1011 // }else{ 1012 // if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && 1013 // checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) { 1014 // if(finishAfterWrongAnswer){ 1015 // goToLastPage(e); 1016 // }else{ 1017 // checked_inputs.parents('div[data-question-id]').find('.ays_
1017next').trigger('click'); 1018 // } 1019 // }else{ 1020 // if(finishAfterWrongAnswer){ 1021 // goToLastPage(e); 1022 // } 1023 // } 1024 // } 1025 // if((wrong_answer_sound)){ 1026 // resetPlaying([right_answer_sound, wrong_answer_sound]); 1027 // setTimeout(function(){ 1028 // wrong_answer_sound.play(); 1029 // }, 10); 1030 // } 1031 // } 1032 // if(showExplanationOn == 'on_passing' || showExplanationOn == 'on_both'){ 1033 // if(! $(e.target).parents('.step').hasClass('not_influence_to_score')){ 1034 // $(e.target).parents().eq(3).find('.ays_questtion_explanation').slideDown(250); 1035 // } 1036 // } 1037 // $(e.target).parents('div[data-question-id]').find('input[name^="ays_questions"]').attr('disabled', true); 1038 // $(e.target).parents('div[data-question-id]').find('input[name^="ays_questions"]').off('change'); 1039 // $(e.target).parents('div[data-question-id]').find('.ays-field').css({ 1040 // 'pointer-events': 'none' 1041 // }); 1042 // }else if(checked_inputs.attr('type') === "checkbox"){ 1043 // checked_inputs = $(e.target); 1044 // if (checked_inputs.length === 1) { 1045 // if(checked_inputs.prev().val() == 1){ 1046 // checked_inputs.parents('.ays-field').addClass('correct_div checked_answer_div'); 1047 // checked_inputs.next().addClass('correct answered'); 1048 // if((right_answer_sound)){ 1049 // resetPlaying([right_answer_sound, wrong_answer_sound]); 1050 // setTimeout(function(){ 1051 // right_answer_sound.play(); 1052 // }, 10); 1053 // } 1054 // }else{ 1055 // checked_inputs.parents('.ays-field').addClass('wrong_div'); 1056 // checked_inputs.next().addClass('wrong answered'); 1057 // if((wrong_answer_sound)){ 1058 // resetPlaying([right_answer_sound, wrong_answer_sound]); 1059 // setTimeout(function(){ 1060 // wrong_answer_sound.play(); 1061 // }, 10); 1062 // } 1063 // if(finishAfterWrongAnswer){ 1064 // goToLastPage(e); 1065 // } 1066 // } 1067 // }else{ 1068 // for (var i = 0; i < checked_inputs.length; i++) { 1069 // if(checked_inputs.eq(i).prev().val() == 1){ 1070 // checked_inputs.eq(i).next().addClass('correct answered'); 1071 // if((right_answer_sound)){ 1072 // resetPlaying([right_answer_sound, wrong_answer_sound]); 1073 // setTimeout(function(){ 1074 // right_answer_sound.play(); 1075 // }, 10); 1076 // } 1077 // }else{ 1078 // checked_inputs.eq(i).next().addClass('wrong answered'); 1079 // if((wrong_answer_sound)){ 1080 // resetPlaying([right_answer_sound, wrong_answer_sound]); 1081 // setTimeout(function(){ 1082 // wrong_answer_sound.play(); 1083 // }, 10); 1084 // } 1085 // if(finishAfterWrongAnswer){ 1086 // goToLastPage(e); 1087 // } 1088 // } 1089 // } 1090 // } 1091 // $(e.target).attr('disabled', true); 1092 // $(e.target).off('change'); 1093 // } 1094 // } 1095 // }else{ 1096 // if($(e.target).attr('type') === 'radio') { 1097 // $(e.target).parents('.ays-quiz-answers').find('.checked_answer_div').removeClass('checked_answer_div'); 1098 // $(e.target).parents('.ays-field').addClass('checked_answer_div'); 1099 // } 1100 // if($(e.target).attr('type') === 'checkbox') { 1101 // if(!$(e.target).parents('.ays-field').hasClass('checked_answer_div')){ 1102 // $(e.target).parents('.ays-field').addClass('checked_answer_div'); 1103 // }else{ 1104 // $(e.target).parents('.ays-field').removeClass('checked_answer_div'); 1105 // } 1106 // } 1107 // var checked_inputs = $(e.target).parents().eq(1).find('input
1107:checked'); 1108 // 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')) { 1109 // if (checked_inputs.attr('type') === 'radio') { 1110 // checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click'); 1111 // } 1112 // } 1113 // } 1114 // }); 1115 1116 $(document).on('input', '.information_form input[name="ays_user_name"]', function(){ 1117 if ($(this).attr('type') !== 'hidden') { 1118 $(this).removeClass('ays_red_border'); 1119 $(this).removeClass('ays_green_border'); 1120 if($(this).val() != ''){ 1121 $(this).addClass('ays_green_border'); 1122 } else { 1123 $(this).addClass('ays_red_border'); 1124 } 1125 } 1126 }); 1127 1128 $(document).on('input', '.information_form input[name="ays_user_phone"]', function(){ 1129 if ($(this).attr('type') !== 'hidden') { 1130 $(this).removeClass('ays_red_border'); 1131 $(this).removeClass('ays_green_border'); 1132 if($(this).val() != ''){ 1133 if (!validatePhoneNumber($(this).get(0))) { 1134 $(this).addClass('ays_red_border'); 1135 }else{ 1136 $(this).addClass('ays_green_border'); 1137 } 1138 } 1139 } 1140 }); 1141 1142 $(document).on('input', '.information_form input[name="ays_user_email"]', function(){ 1143 if ($(this).attr('type') !== 'hidden') { 1144 $(this).removeClass('ays_red_border'); 1145 $(this).removeClass('ays_green_border'); 1146 if($(this).val() != ''){ 1147 if (!(emailValivatePattern.test($(this).val().trim()))) { 1148 $(this).addClass('ays_red_border'); 1149 }else{ 1150 $(this).addClass('ays_green_border'); 1151 } 1152 } 1153 } 1154 }); 1155 1156 $(document).on('input', 'input.ays_quiz_password', function(e){ 1157 var $this = $(this); 1158 var startButton = $this.parents('.ays-quiz-container').find('input.start_button'); 1159 if($this.val() != ''){ 1160 startButton.removeAttr('disabled'); 1161 }else{ 1162 startButton.attr('disabled', 'disabled'); 1163 } 1164 }); 1165 1166 $(document).on('click', '.ays-quiz-password-toggle', function(e){ 1167 var $this = $(this); 1168 1169 var parent = $this.parents('.ays-quiz-password-toggle-visibility-box'); 1170 var passwordInput = parent.find('.ays_quiz_password'); 1171 1172 var visibilityOn = parent.find('.ays-quiz-password-toggle-visibility'); 1173 var visibilityOff = parent.find('.ays-quiz-password-toggle-visibility-off'); 1174 1175 if( $this.hasClass('ays-quiz-password-toggle-visibility-off') ) { 1176 passwordInput.attr('type', 'text'); 1177 1178 if ( visibilityOn.hasClass('ays_display_none') ) { 1179 visibilityOn.removeClass('ays_display_none'); 1180 } 1181 1182 if ( ! visibilityOff.hasClass('ays_display_none') ) { 1183 visibilityOff.addClass('ays_display_none'); 1184 } 1185 1186 } else if( $this.hasClass('ays-quiz-password-toggle-visibility') ) { 1187 passwordInput.attr('type', 'password'); 1188 1189 if ( ! visibilityOn.hasClass('ays_display_none') ) { 1190 visibilityOn.addClass('ays_display_none'); 1191 } 1192 1193 if ( visibilityOff.hasClass('ays_display_none') ) { 1194 visibilityOff.removeClass('ays_display_none'); 1195 } 1196 } 1197 }); 1198 1199 1200 setTimeout(function(){ 1201 $(document).find('input.ays_quiz_password').val(''); 1202 }, 500); 1203 1204 $(document).find('.ays-text-field .ays-text-input').each(function(ev){ 1205 $(this).on('keydown', function(e){ 1206 myOptions.enable_enter_key = !( myOptions.enable_enter_key ) ? "on" : myOptions.enable_enter_key; 1207 var enableEnterKey = (myOptions.enable_enter_key && myOptions.enable_enter_key == "on") ? true : false;
1208 1209 myOptions.quiz_enable_keyboard_navigation = !( myOptions.quiz_enable_keyboard_navigation ) ? "on" : myOptions.quiz_enable_keyboard_navigation; 1210 var isKeyboardNavigation = (myOptions.quiz_enable_keyboard_navigation && myOptions.quiz_enable_keyboard_navigation == "on") ? true : false; 1211 1212 if(enableEnterKey || isKeyboardNavigation){ 1213 if (e.keyCode === 13 && !e.shiftKey) { 1214 if(animating){ 1215 return false; 1216 } 1217 1218 if($(this).parents('.step').find('input.ays_finish.action-button').length > 0){ 1219 $(this).parents('.step').find('input.ays_finish.action-button').trigger('click'); 1220 }else{ 1221 $(this).parents('.step').find('input.ays_next.action-button').trigger('click'); 1222 } 1223 return false; 1224 } 1225 } 1226 }); 1227 }); 1228 1229 $(document).on('click', '.ays_next', function(e){ 1230 e.preventDefault(); 1231 var quizId = $(this).parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val(); 1232 1233 if(checkQuizPassword(e, myOptions, true) === false){ 1234 return false; 1235 } 1236 1237 if ( typeof window.aysSeeResultConfirmBox[ quizId ] != 'undefined' && window.aysSeeResultConfirmBox[ quizId ] ) { 1238 window.aysSeeResultConfirmBox[ quizId ] = false; 1239 return false; 1240 } 1241 1242 if(typeof explanationTimeout != 'undefined'){ 1243 clearTimeout(explanationTimeout); 1244 } 1245 ays_quiz_container = $(this).parents(".ays-quiz-container"); 1246 if (!($(this).hasClass('start_button'))) { 1247 if ($(this).parents('.step').find('input[required]').length !== 0) { 1248 var empty_inputs = 0; 1249 var required_inputs = $(this).parents('.step').find('input[required]'); 1250 $(this).parents('.step').find('.ays_red_border').removeClass('ays_red_border'); 1251 $(this).parents('.step').find('.ays_green_border').removeClass('ays_green_border'); 1252 for (var i = 0; i < required_inputs.length; i++) { 1253 switch(required_inputs.eq(i).attr('name')){ 1254 case "ays_user_phone": { 1255 if (!validatePhoneNumber(required_inputs.eq(i).get(0))) { 1256 required_inputs.eq(i).addClass('ays_red_border'); 1257 required_inputs.eq(i).addClass('shake'); 1258 empty_inputs++; 1259 } 1260 break; 1261 } 1262 case "ays_user_email": { 1263 if (!(emailValivatePattern.test(required_inputs.eq(i).val().trim()))) { 1264 required_inputs.eq(i).addClass('ays_red_border'); 1265 required_inputs.eq(i).addClass('shake'); 1266 empty_inputs++; 1267 } 1268 break; 1269 } 1270 default:{ 1271 if (required_inputs.eq(i).val() === '' && 1272 required_inputs.eq(i).attr('type') !== 'hidden') { 1273 required_inputs.eq(i).addClass('ays_red_border'); 1274 required_inputs.eq(i).addClass('shake'); 1275 empty_inputs++; 1276 } 1277 break; 1278 } 1279 } 1280 } 1281 var empty_inputs2 = 0; 1282 var phoneInput = $(this).parents('.step').find('input[name="ays_user_phone"]'); 1283 var emailInput = $(this).parents('.step').find('input[name="ays_user_email"]'); 1284 if(phoneInput.val() != ''){ 1285 phoneInput.removeClass('ays_red_border'); 1286 phoneInput.removeClass('ays_green_border'); 1287 if (!validatePhoneNumber(phoneInput.get(0))) { 1288 if (phoneInput.attr('type') !== 'hidden') { 1289 phoneInput.addClass('ays_red_border'); 1290 phoneInput.addClass('shake'); 1291 empty_inputs2++; 1292 } 1293 }else{ 1294 phoneInput.addClass('ays_green_border'); 1295 } 1296 } 1297 if(emailInput.val() != ''){ 1298 emailInput.removeClass('ays_red_border'); 1299 emailInput.removeClass('ays_green_border'); 1300 if (!(emailValivatePattern.test(emailInput.val().trim()))) { 1301 if (emailInput.attr('type') !== 'hidden') { 1302 emailInput.addClass('ays_red_border'); 1303 emailInput.addClass('shake'); 1304 empty_inputs2++; 1305 } 1306 }else{ 1307 emailInput.addClass('ays_green_border'); 1308 } 1309 } 1310 var errorFields = $(this).parents('.step').find('.ays_red_border'); 1311 if (empty_inputs2 !== 0 || empty_inputs !== 0) { 1312 setTimeout(function(){ 1313 errorFields.each(function(){ 1314 $(this).removeClass('shake'); 1315 }); 1316 }, 500); 1317 setTimeout(function(){ 1318 required_inputs.each(function(){ 1319 $(this).removeClass('shake'); 1320 }); 1321 }, 500); 1322 return false;
1323 }else{ 1324 $(this).addClass('ays_start_allow'); 1325 } 1326 }else{ 1327 if ($(this).parents('.step').find('.information_form').length !== 0 ){ 1328 var empty_inputs = 0; 1329 var phoneInput = $(this).parents('.step').find('input[name="ays_user_phone"]'); 1330 var emailInput = $(this).parents('.step').find('input[name="ays_user_email"]'); 1331 if(phoneInput.val() != ''){ 1332 phoneInput.removeClass('ays_red_border'); 1333 phoneInput.removeClass('ays_green_border'); 1334 if (!validatePhoneNumber(phoneInput.get(0))) { 1335 if (phoneInput.attr('type') !== 'hidden') { 1336 phoneInput.addClass('ays_red_border'); 1337 phoneInput.addClass('shake'); 1338 empty_inputs++; 1339 } 1340 }else{ 1341 phoneInput.addClass('ays_green_border'); 1342 } 1343 } 1344 if(emailInput.val() != ''){ 1345 emailInput.removeClass('ays_red_border'); 1346 emailInput.removeClass('ays_green_border'); 1347 if (!(emailValivatePattern.test(emailInput.val().trim()))) { 1348 if (emailInput.attr('type') !== 'hidden') { 1349 emailInput.addClass('ays_red_border'); 1350 emailInput.addClass('shake'); 1351 empty_inputs++; 1352 } 1353 }else{ 1354 emailInput.addClass('ays_green_border'); 1355 } 1356 } 1357 var errorFields = $(this).parents('.step').find('.ays_red_border'); 1358 if (empty_inputs !== 0) { 1359 setTimeout(function(){ 1360 errorFields.each(function(){ 1361 $(this).removeClass('shake'); 1362 }); 1363 }, 500); 1364 return false; 1365 } 1366 $(this).addClass('ays_start_allow'); 1367 } 1368 } 1369 } 1370 1371 if (animating) return false; 1372 animating = true; 1373 current_fs = $(this).parents('.step'); 1374 next_fs = $(this).parents('.step').next(); 1375 var questions_count = $(this).parents('form').find('div[data-question-id]').length; 1376 var curent_number = $(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]')) + 1; 1377 var next_sibilings_count = $(this).parents('form').find('.ays_question_count_per_page').val(); 1378 1379 // Display all questions on one page 1380 myOptions.quiz_display_all_questions = ( myOptions.quiz_display_all_questions ) ? myOptions.quiz_display_all_questions : 'off'; 1381 var quiz_display_all_questions = (myOptions.quiz_display_all_questions && myOptions.quiz_display_all_questions == "on") ? true : false; 1382 1383 if ( quiz_display_all_questions ) { 1384 next_sibilings_count = questions_count; 1385 } 1386 1387 // Disable input focusing 1388 myOptions.quiz_disable_input_focusing = ( myOptions.quiz_disable_input_focusing ) ? myOptions.quiz_disable_input_focusing : 'off'; 1389 var quizDisableInputFocusing = (myOptions.quiz_disable_input_focusing && myOptions.quiz_disable_input_focusing == "on") ? true : false; 1390 1391 if(parseInt(next_sibilings_count)>0 && ($(this).parents('.step').attr('data-question-id') || $(this).parents('.step').next().attr('data-question-id'))){ 1392 1393 if(parseInt(next_sibilings_count) >= questions_count){ 1394 next_sibilings_count = questions_count; 1395 } 1396 1397 var current_fs_index = $(this).parents('form').find('.step').index($(this).parents('.step')); 1398 if($(this).parents('.step').attr('data-question-id')){ 1399 current_fs = $(this).parents('form').find('.step').slice(current_fs_index-parseInt(next_sibilings_count),current_fs_index+1); 1400 }else{ 1401 current_fs = $(this).parents('.step'); 1402 } 1403 if(questions_count === curent_number){ 1404 if(current_fs.hasClass('.information_form').length !== 0){
1405 current_fs.find('.ays_next').eq(current_fs.find('.ays_next').length-1).addClass('ays_timer_end'); 1406 current_fs.parents('.ays-quiz-container').find('.ays-quiz-timer').slideUp(500); 1407 // setTimeout(function () { 1408 // current_fs.parents('.ays-quiz-container').find('.ays-quiz-timer').parent().hide(); 1409 // },500); 1410 } 1411 } 1412 1413 if(curent_number != questions_count){ 1414 if(($(this).hasClass('ays_finish')) == false){ 1415 if (!($(this).hasClass('start_button'))) { 1416 var count_per_page = Math.floor(questions_count/parseInt(next_sibilings_count)); 1417 var nextCountQuestionsPerPage = questions_count-curent_number; 1418 var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width(); 1419 var final_width = ((curent_number+parseInt(next_sibilings_count)) / questions_count * 100) + "%"; 1420 if(nextCountQuestionsPerPage < parseInt(next_sibilings_count)){ 1421 final_width = ((curent_number+nextCountQuestionsPerPage) / questions_count * 100) + "%"; 1422 } 1423 if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ 1424 if(nextCountQuestionsPerPage < parseInt(next_sibilings_count)){ 1425 $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+parseInt(nextCountQuestionsPerPage))); 1426 }else{ 1427 $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+parseInt(next_sibilings_count))); 1428 } 1429 }else{ 1430 $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width)); 1431 } 1432 $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000); 1433 } 1434 } 1435 }else{ 1436 $(this).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut'); 1437 setTimeout(function () { 1438 $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none'); 1439 },300) 1440 } 1441 var next_siblings = $(this).parents('.step').nextAll('.step').slice(0,parseInt(next_sibilings_count)); 1442 1443 if($(this).parents('form').find('div[data-question-id]').index($(this).parents('.step'))+1 !== $(this).parents('form').find('div[data-question-id]').length) { 1444 for (var z = 0; z < next_siblings.length; z++) { 1445 if (next_siblings.eq(z).attr('data-question-id') === undefined) { 1446 next_siblings.splice(z); 1447 } 1448 } 1449 }else{ 1450 if(next_siblings.length !== 1) { 1451 next_siblings.splice(next_siblings.length - 1); 1452 } 1453 } 1454 $(e.target).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', false); 1455 for(var i=0 ;i<next_siblings.length-1;i++){ 1456 var nextQuestionType = next_siblings.eq(i).find('input[name^="ays_questions"]').attr('type'); 1457 var buttonsDiv = next_siblings.eq(i).find('.ays_buttons_div'); 1458 next_siblings.eq(i).find('.ays_previous').remove(); 1459 if(i === next_siblings.length-1 && next_siblings.eq(i).find('textarea[name^="ays_questions"]').attr('type')==='text'){ 1460 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1461 continue; 1462 } 1463 if(i === next_siblings.length-1 && nextQuestionType === 'checkbox'){ 1464 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1465 continue; 1466 } 1467 if(i === next_siblings.length-1 && nextQuestionType === 'number'){ 1468 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1469 continue; 1470 } 1471 if(i === next_siblings.length-1 && nextQuestionType === 'text'){ 1472 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1473 continue; 1474 } 1475 if(i === next_siblings.length-1 && nextQuestionType === 'date'){ 1476 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1477 continue; 1478 }
1479 next_siblings.eq(i).find('.ays_next').remove(); 1480 next_siblings.eq(i).find('.ays_early_finish').remove(); 1481 } 1482 1483 next_siblings.find('.ays_previous').remove(); 1484 1485 if(current_fs.hasClass('ays-abs-fs')){ 1486 current_fs = $(this).parents('.step'); 1487 next_fs = $(this).parents('.step').next(); 1488 current_fs.removeClass('active-step'); 1489 var counterClass = ""; 1490 switch(ays_quiz_container.data('questEffect')){ 1491 case "shake": 1492 counterClass = ays_quiz_container.data('questEffect'); 1493 break; 1494 case "fade": 1495 counterClass = "fadeIn"; 1496 break; 1497 case "none": 1498 counterClass = ""; 1499 break; 1500 default: 1501 counterClass = ays_quiz_container.data('questEffect'); 1502 break; 1503 } 1504 next_fs.find('.ays-question-counter').addClass(counterClass); 1505 1506 } 1507 1508 var nextQuestionType = next_siblings.eq(next_siblings.length-1).find('input[name^="ays_questions"]').attr('type'); 1509 var buttonsDiv = next_siblings.eq(next_siblings.length-1).find('.ays_buttons_div'); 1510 var enableArrows = $(document).find(".ays-questions-container .ays_qm_enable_arrows").val(); 1511 if(myOptions.enable_arrows){ 1512 enableArrows = myOptions.enable_arrows == 'on' ? true : false; 1513 }else{ 1514 enableArrows = parseInt(enableArrows) == 1 ? true : false; 1515 } 1516 1517 buttonsDiv.find('i.ays_early_finish').addClass('ays_display_none'); 1518 buttonsDiv.find('input.ays_early_finish').addClass('ays_display_none'); 1519 1520 var nextArrowIsDisabled = buttonsDiv.find('.ays_fa_arrow_right').hasClass('ays_display_none'); 1521 var nextButtonIsDisabled = buttonsDiv.find('.ays_next').hasClass('ays_display_none'); 1522 1523 // if(nextArrowIsDisabled && nextButtonIsDisabled){ 1524 // buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1525 // } 1526 if( enableArrows ){ 1527 buttonsDiv.find('input.ays_next').addClass('ays_display_none'); 1528 buttonsDiv.find('input.ays_finish').addClass('ays_display_none'); 1529 1530 buttonsDiv.find('.ays_fa_arrow_right').removeClass('ays_display_none'); 1531 buttonsDiv.find('.ays_arrow.ays_finish').removeClass('ays_display_none'); 1532 } else { 1533 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1534 buttonsDiv.find('input.ays_finish').removeClass('ays_display_none'); 1535 } 1536 1537 1538 if(nextQuestionType === 'checkbox' && nextArrowIsDisabled && nextButtonIsDisabled){ 1539 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1540 } 1541 if(nextQuestionType === 'checkbox' && enableArrows){ 1542 buttonsDiv.find('input.ays_next').addClass('ays_display_none'); 1543 buttonsDiv.find('.ays_fa_arrow_right').removeClass('ays_display_none'); 1544 } 1545 if(nextQuestionType === 'number' && nextArrowIsDisabled && nextButtonIsDisabled){ 1546 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1547 } 1548 if(nextQuestionType === 'number' && enableArrows){ 1549 buttonsDiv.find('input.ays_next').addClass('ays_display_none'); 1550 buttonsDiv.find('.ays_fa_arrow_right').removeClass('ays_display_none'); 1551 } 1552 if(nextQuestionType === 'text' && nextArrowIsDisabled && nextButtonIsDisabled){ 1553 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1554 } 1555 if(nextQuestionType === 'text' && enableArrows){ 1556 buttonsDiv.find('input.ays_next').addClass('ays_display_none'); 1557 buttonsDiv.find('.ays_fa_arrow_right').removeClass('ays_display_none'); 1558 } 1559 if(nextQuestionType === 'date' && nextArrowIsDisabled && nextButtonIsDisabled){ 1560 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1561 } 1562 if(nextQuestionType === 'date' && enableArrows){ 1563 buttonsDiv.find('input.ays_next').addClass('ays_display_none'); 1564 buttonsDiv.find('.ays_fa_arrow_right').removeClass('ays_display_none'); 1565 } 1566 1567 if (!($(this).hasClass('start_button')) && window.aysTimerIntervalFlag == null) { 1568 var minSelHasError = 0; 1569 var minSelQuestions = next_siblings; 1570 // if(($(this).hasClass('ays_finish')) == false){ 1571 // minSelQuestions = next_siblings; 1572 // }else{ 1573 minSelQuestions = current_fs; 1574 // } 1575 for( var k = 0; k < minSelQuestions.length; k++ ){ 1576 if( $( minSelQuestions[k] ).find('.enable_min_selection_number').length > 0 ){ 1577 var checkedMinSelCount = aysCheckMinimumCountCheckbox( $( minSelQuestions[k] ), myQuizOptions ); 1578 if( ays_quiz_is_question_min_count( $( minSelQuestions[k] ), !checkedMinSelCount ) === true ){ 1579 if( checkedMinSelCount == true ){ 1580 if(enableArrows){ 1581 buttonsDiv.find('i.ays_next_arrow').removeAttr('disabled'); 1582 buttonsDiv.find('i.ays_next_arrow').prop('disabled', false); 1583 }else{ 1584 buttonsDiv.find('input.ays_next').removeAttr('disabled'); 1585 buttonsDiv.find('input.ays_next').prop('disabled', false); 1586 } 1587 }else{ 1588 if(enableArrows){ 1589 buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled'); 1590 buttonsDiv.find('i.ays_next_arrow').prop('disabled', true); 1591 buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none'); 1592 }else{ 1593 buttonsDiv.find('input.ays_next').attr('disabled', 'disabled'); 1594 buttonsDiv.find('input.ays_next').prop('disabled', true); 1595 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1596 } 1597 minSelHasError++; 1598 } 1599 }else{ 1600 if(enableArrows){ 1601 buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled'); 1602 buttonsDiv.find('i.ays_next_arrow').prop('disabled', true); 1603 buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none'); 1604 }else{ 1605 buttonsDiv.find('input.ays_next').attr('disabled', 'disabled'); 1606 buttonsDiv.find('input.ays_next').prop('disabled', true); 1607 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1608 } 1609 minSelHasError++; 1610 } 1611 } 1612 } 1613 if( minSelHasError > 0 ){ 1614 return false;
1615 } 1616 } 1617 1618 ays_quiz_container.find('.active-step').removeClass('active-step'); 1619 next_siblings.eq(0).addClass('active-step'); 1620 aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_siblings); 1621 1622 if( !quizDisableInputFocusing ){ 1623 next_siblings.eq(0).find('.ays-text-input').trigger( "focus" ); 1624 if ( ! next_siblings.eq(0).find('.ays-text-input').is(":focus") ) { 1625 setTimeout(function(e){ 1626 next_siblings.eq(0).find('.ays-text-input').trigger( "focus" ); 1627 },1001); 1628 } 1629 } 1630 1631 setTimeout(function(){ 1632 if(next_siblings.find('.ays-text-field').length > 0){ 1633 if(next_siblings.find('.ays-text-field').width() < 250){ 1634 next_siblings.find('.ays-text-field').css({ 1635 'flex-wrap': 'wrap', 1636 'justify-content': 'center', 1637 'padding': '5px' 1638 }); 1639 next_siblings.find('.ays-text-field').find('input.ays-text-input').css('margin-bottom', '5px'); 1640 } 1641 } 1642 },2000); 1643 }else{ 1644 current_fs = $(this).parents('.step'); 1645 next_fs = $(this).parents('.step').next(); 1646 var questions_count = $(this).parents('form').find('div[data-question-id]').length; 1647 var curent_number = $(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]'))+1; 1648 if(questions_count === curent_number){ 1649 if(current_fs.hasClass('.information_form').length !== 0){ 1650 current_fs.find('.ays_next').addClass('ays_timer_end'); 1651 current_fs.parents('.ays-quiz-container').find('.ays-quiz-timer').slideUp(500); 1652 // setTimeout(function () { 1653 // current_fs.parents('.ays-quiz-container').find('.ays-quiz-timer').parent().hide(); 1654 // },500); 1655 } 1656 } 1657 if(curent_number != questions_count){ 1658 if(($(this).hasClass('ays_finish')) == false){ 1659 if (!($(this).hasClass('start_button'))) { 1660 var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width(); 1661 var final_width = ((curent_number+1) / questions_count * 100) + "%"; 1662 if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ 1663 $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+1)); 1664 }else{ 1665 $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width)); 1666 } 1667 $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000); 1668 } 1669 } 1670 }else{ 1671 $(this).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut'); 1672 setTimeout(function () { 1673 $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none'); 1674 },300) 1675 } 1676 if ($(this).parents('form').hasClass('enable_correction')) { 1677 if (next_fs.find('.correct').length === 0 && 1678 next_fs.find('.wrong').length === 0 && 1679 next_fs.find('.ays-answered-text-input').length === 0) { 1680 next_fs.find('input[name^="ays_questions"]').attr('disabled', false); 1681 } 1682 } 1683 if (current_fs.hasClass('ays-abs-fs')) { 1684 current_fs = $(this).parents('.step'); 1685 next_fs = $(this).parents('.step').next(); 1686 var counterClass = ""; 1687 switch(ays_quiz_container.data('questEffect')){ 1688 case "shake": 1689 counterClass = ays_quiz_container.data('questEffect'); 1690 break; 1691 case "fade": 1692 counterClass = "fadeIn"; 1693 break; 1694 case "none": 1695 counterClass = ""; 1696 break; 1697 default: 1698 counterClass = ays_quiz_container.data('questEffect'); 1699 break; 1700 } 1701 next_fs.find('.ays-question-counter').addClass(counterClass); 1702 } 1703 current_fs.removeClass('active-step'); 1704 next_fs.addClass('active-step'); 1705 var nextQuestionType = next_fs.find('input[name^="ays_questions"]').attr('type'); 1706 var buttonsDiv = next_fs.find('.ays_buttons_div'); 1707 var enableArrows = $(document).find(".ays-questions-container .ays_qm_enable_arrows").val(); 1708 if(myOptions.enable_arrows){ 1709 enableArrows = myOptions.enable_arrows == 'on' ? true : false;
1710 }else{ 1711 enableArrows = parseInt(enableArrows) == 1 ? true : false; 1712 } 1713 var nextArrowIsDisabled = buttonsDiv.find('.ays_next_arrow').hasClass('ays_display_none'); 1714 var nextButtonIsDisabled = buttonsDiv.find('.ays_next').hasClass('ays_display_none'); 1715 1716 1717 if(nextQuestionType === 'checkbox' && nextArrowIsDisabled && nextButtonIsDisabled){ 1718 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1719 } 1720 if(nextQuestionType === 'checkbox' && enableArrows){ 1721 buttonsDiv.find('input.ays_next').addClass('ays_display_none'); 1722 buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none'); 1723 } 1724 1725 1726 if(nextQuestionType === 'number' && nextArrowIsDisabled && nextButtonIsDisabled){ 1727 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1728 } 1729 if(nextQuestionType === 'number' && enableArrows){ 1730 buttonsDiv.find('input.ays_next').addClass('ays_display_none'); 1731 buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none'); 1732 } 1733 1734 if(next_fs.find('textarea[name^="ays_questions"]').attr('type')==='text' && nextArrowIsDisabled && nextButtonIsDisabled){ 1735 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1736 } 1737 if(next_fs.find('textarea[name^="ays_questions"]').attr('type')==='text' && enableArrows){ 1738 buttonsDiv.find('input.ays_next').addClass('ays_display_none'); 1739 buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none'); 1740 } 1741 1742 if(nextQuestionType === 'text' && nextArrowIsDisabled && nextButtonIsDisabled){ 1743 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1744 } 1745 if(nextQuestionType === 'text' && enableArrows){ 1746 buttonsDiv.find('input.ays_next').addClass('ays_display_none'); 1747 buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none'); 1748 } 1749 1750 if(nextQuestionType === 'date' && nextArrowIsDisabled && nextButtonIsDisabled){ 1751 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1752 } 1753 if(nextQuestionType === 'date' && enableArrows){ 1754 buttonsDiv.find('input.ays_next').addClass('ays_display_none'); 1755 buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none'); 1756 } 1757 1758 aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs); 1759 1760 if( !quizDisableInputFocusing ){ 1761 next_fs.find('.ays-text-input').trigger( "focus" ); 1762 if ( ! next_fs.find('.ays-text-input').is(":focus") ) { 1763 setTimeout(function(e){ 1764 next_fs.find('.ays-text-input').trigger( "focus" ); 1765 },1001); 1766 } 1767 } 1768 1769 setTimeout(function(){ 1770 if(next_fs.find('.ays-text-field').length > 0){ 1771 if(next_fs.find('.ays-text-field').width() < 250){ 1772 next_fs.find('.ays-text-field').css({ 1773 'flex-wrap': 'wrap', 1774 'justify-content': 'center', 1775 'padding': '5px' 1776 }); 1777 next_fs.find('.ays-text-field').find('input.ays-text-input').css('margin-bottom', '5px'); 1778 } 1779 } 1780 },2000); 1781 } 1782 if($(document).scrollTop() >= $(this).parents('.ays-questions-container').offset().top){ 1783 ays_quiz_container.goTo(myOptions); 1784 } 1785 if(current_fs.find('audio').length > 0){ 1786 current_fs.find('audio').each(function(e, el){ 1787 el.pause(); 1788 }); 1789 } 1790 if(current_fs.find('video').length > 0){ 1791 current_fs.find('video').each(function(e, el){ 1792 el.pause(); 1793 }); 1794 } 1795 1796 //Current 1797 if(current_fs.find('audio').length > 0){ 1798 var sound_src = next_fs.find('audio').attr('src'); 1799 if (typeof sound_src !== 'undefined'){ 1800 var audio = next_fs.find('audio').get(0); 1801 audio.pause(); 1802 audio.currentTime = 0; 1803 } 1804 } 1805 //Next 1806 var enableAudioAutoplay = (myOptions.enable_audio_autoplay && myOptions.enable_audio_autoplay == 'on') ? 'on' : 'off'; 1807 if(next_fs.find('audio').length > 0){ 1808 if(enableAudioAutoplay === 'on'){ 1809 var sound_src = next_fs.find('audio').attr('src'); 1810 if (typeof sound_src !== 'undefined'){ 1811 var audio = next_fs.find('audio').get(0); 1812 audio.currentTime = 0; 1813 audio.play(); 1814 } 1815 } 1816 } 1817 1818 }); 1819 1820 $(document).on("click", '.ays_previous', function(e){ 1821 ays_quiz_container = $(this).parents(".ays-quiz-container"); 1822 if(typeof explanationTimeout != 'undefined'){ 1823 clearTimeout(explanationTimeout); 1824 var thisButtonsDiv = $(this).parents(".ays_buttons_div"); 1825 setTimeout(function(){ 1826 if (thisButtonsDiv.find('input.ays_next').hasClass('ays_display_none') && 1827 thisButtonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none')) { 1828 if(enableArrows){ 1829 thisButtonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none'); 1830 }else{ 1831 thisButtonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1832 } 1833 } 1834 }, 1000); 1835 } 1836 1837 if(animating) return false;
1838 animating = true; 1839 var next_sibilings_count = $(this).parents('form').find('.ays_question_count_per_page').val(); 1840 1841 // Disable input focusing 1842 myOptions.quiz_disable_input_focusing = ( myOptions.quiz_disable_input_focusing ) ? myOptions.quiz_disable_input_focusing : 'off'; 1843 var quizDisableInputFocusing = (myOptions.quiz_disable_input_focusing && myOptions.quiz_disable_input_focusing == "on") ? true : false; 1844 1845 if(parseInt(next_sibilings_count)>0 && ($(this).parents('.step').attr('data-question-id') || $(this).parents('.step').next().attr('data-question-id'))){ 1846 var questions_count = $(this).parents('form').find('div[data-question-id]').length; 1847 var curent_number_of_this = $(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]')) + 1; 1848 var curent_number = $(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]')) - parseInt(next_sibilings_count) + 1; 1849 var count_per_page = questions_count%parseInt(next_sibilings_count); 1850 var nextCountQuestionsPerPage = questions_count-curent_number; 1851 if(count_per_page > 0 && curent_number_of_this == questions_count){ 1852 curent_number = $(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]')) - count_per_page + 1; 1853 } 1854 if (!($(this).hasClass('start_button'))) { 1855 var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width(); 1856 var final_width = ((curent_number) / questions_count * 100) + "%"; 1857 if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ 1858 $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number)); 1859 }else{ 1860 $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width)); 1861 } 1862 $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000); 1863 } 1864 var current_fs_index = $(this).parents('form').find('div[data-question-id]').index($(this).parents('form').find('.active-step').eq(0)); 1865 if($(this).parents('.step').attr('data-question-id')){ 1866 current_fs = $(this).parents('form').find('div[data-question-id]').slice(current_fs_index,current_fs_index+parseInt(next_sibilings_count)); 1867 }else{ 1868 current_fs = $(this).parent(); 1869 } 1870 1871 var current_first_fs_index = $(this).parents('form').find('div[data-question-id]').index($(this).parents('form').find('.active-step').eq(0)); 1872 var next_fs = $('div[data-question-id]').slice((current_first_fs_index - parseInt(next_sibilings_count)), current_first_fs_index); 1873 1874 var buttonsDiv = next_fs.find('.ays_buttons_div'); 1875 var enableArrows = $(document).find(".ays-questions-container .ays_qm_enable_arrows").val(); 1876 if(myOptions.enable_arrows){ 1877 enableArrows = myOptions.enable_arrows == 'on' ? true : false; 1878 }else{ 1879 enableArrows = parseInt(enableArrows) == 1 ? true : false; 1880 } 1881 1882 if (buttonsDiv.find('input.ays_next').hasClass('ays_display_none') && 1883 buttonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none')) { 1884 if(enableArrows){ 1885 buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none'); 1886 }else{ 1887 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1888 } 1889 } 1890 1891 $(this).parents('form').find('div[data-question-id]').eq(current_fs_index).removeClass('active-step'); 1892 next_fs.eq(0).addClass('active-step') 1893 if ($(this).parents('form').hasClass('enable_correction')) { 1894 if (next_fs.find('.correct').length !== 0 || $(this).parents('div[data-question-id]').prev().find('.wrong').length !== 0) { 1895 next_fs.find('input[name^="ays_questions"]').on('click',function () { 1896 return false;
1897 }); 1898 } 1899 } 1900 1901 $(e.target).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', false); 1902 aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs); 1903 1904 }else{ 1905 if ($(this).parents('form').hasClass('enable_correction')) { 1906 if ($(this).parents('div[data-question-id]').prev().find('.correct').length === 0 && 1907 $(this).parents('div[data-question-id]').prev().find('.wrong').length === 0 && 1908 $(this).parents('div[data-question-id]').prev().find('.ays-answered-text-input').length === 0) { 1909 $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"]').attr('disabled', false); 1910 }else{ 1911 $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"]').attr('disabled', true); 1912 if( $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"]').attr('type') == 'checkbox' ){ 1913 $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"]').attr('disabled', false); 1914 $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"][type="radio"]').on('click',function () { 1915 return false; 1916 }); 1917 } 1918 } 1919 } 1920 current_fs = $(this).parents('.step'); 1921 next_fs = $(this).parents('.step').prev(); 1922 1923 var buttonsDiv = next_fs.find('.ays_buttons_div'); 1924 var enableArrows = $(document).find(".ays-questions-container .ays_qm_enable_arrows").val(); 1925 if(myOptions.enable_arrows){ 1926 enableArrows = myOptions.enable_arrows == 'on' ? true : false; 1927 }else{ 1928 enableArrows = parseInt(enableArrows) == 1 ? true : false; 1929 } 1930 1931 if (buttonsDiv.find('input.ays_next').hasClass('ays_display_none') && 1932 buttonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none')) { 1933 if(enableArrows){ 1934 buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none'); 1935 }else{ 1936 buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); 1937 } 1938 } 1939 1940 if (current_fs.hasClass('ays-abs-fs')) { 1941 current_fs = $(this).parent().parent().parent(); 1942 next_fs = $(this).parent().parent().parent().prev(); 1943 var counterClass = ""; 1944 switch(ays_quiz_container.data('questEffect')){ 1945 case "shake": 1946 counterClass = ays_quiz_container.data('questEffect'); 1947 break; 1948 case "fade": 1949 counterClass = "fadeIn"; 1950 break; 1951 case "none": 1952 counterClass = ""; 1953 break; 1954 default: 1955 counterClass = ays_quiz_container.data('questEffect'); 1956 break; 1957 } 1958 next_fs.find('.ays-question-counter').addClass(counterClass); 1959 } 1960 current_fs.removeClass('active-step'); 1961 next_fs.addClass('active-step'); 1962 1963 var questions_count = $(this).parents('form').find('div[data-question-id]').length; 1964 var curent_number = $(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]'))-1; 1965 if(curent_number != questions_count){ 1966 if(($(this).hasClass('ays_finish')) == false){ 1967 if (!($(this).hasClass('start_button'))) { 1968 var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width(); 1969 var final_width = ((curent_number+1) / questions_count * 100) + "%"; 1970 if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ 1971 $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+1)); 1972 }else{ 1973 $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width)); 1974 } 1975 $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000); 1976 } 1977 } 1978 }else{ 1979 $(this).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut'); 1980 setTimeout(function () { 1981 $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none'); 1982 },300) 1983 } 1984 1985 aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs); 1986 if( !quizDisableInputFocusing ){ 1987 next_fs.find('.ays-text-input').trigger( "focus" ); 1988 if ( ! next_fs.find('.ays-text-input').is(":focus") ) { 1989 setTimeout(function(e){ 1990 next_fs.find('.ays-text-input').trigger( "focus" ); 1991 },1001); 1992 } 1993 } 1994 } 1995 if($(document).scrollTop() >= $(this).parents('.ays-questions-container').offset().top){ 1996 ays_quiz_container.goTo(myOptions); 1997 } 1998 if(current_fs.find('audio').length > 0){ 1999 current_fs.find('audio').each(function(e, el){ 2000 el.pause(); 2001 }); 2002 } 2003 if(current_fs.find('video').length > 0){ 2004 current_fs.find('video').each(function(e, el){ 2005 el.pause(); 2006 }); 2007 } 2008 2009 //Current 2010 if(current_fs.find('audio').length > 0){ 2011 var sound_src = next_fs.find('audio').attr('src'); 2012 if (typeof sound_src !== 'undefined'){ 2013 var audio = next_fs.find('audio').get(0); 2014 audio.pause(); 2015 audio.currentTime = 0; 2016 } 2017 } 2018 //Previous 2019 var enableAudioAutoplay = (myOptions.enable_audio_autoplay && myOptions.enable_audio_autoplay == 'on') ? 'on' : 'off'; 2020 if(next_fs.find('audio').length > 0){ 2021 if(enableAudioAutoplay === 'on'){ 2022 var sound_src = next_fs.find('audio').attr('src'); 2023 if (typeof sound_src !== 'undefined'){ 2024 var audio = next_fs.find('audio').get(0); 2025 audio.currentTime = 0; 2026 audio.play(); 2027 } 2028 } 2029 } 2030 }); 2031 2032 $(document).on('click', '.ays-quiz-container .ays_question_hint', function (e) { 2033 e.preventDefault(); 2034 2035 $(e.target).parents('.ays-quiz-container').find('.ays_music_sound').toggleClass('z_index_0'); 2036 $(e.target).parent().find('.ays_question_hint_text').toggleClass('show_hint'); 2037 if($(e.target).parent().find('.ays_question_hint_text').hasClass('show_hint')){ 2038 $(window).on('click', function(ev){ 2039 if( ! ( $(ev.target).hasClass('ays_question_hint_text') || $(ev.target).hasClass('ays_question_hint') ) ){ 2040 $(e.target).parent().find('.ays_question_hint_text').removeClass('show_hint') 2041 $(e.target).parents('.ays-quiz-container').find('.ays_music_sound').removeClass('z_index_0'); 2042 } 2043 }); 2044 } 2045 }); 2046 2047 $(document).on('click', '.ays-field', function() { 2048 if ($(this).find(".select2").hasClass('select2-container--open')) { 2049 $(this).find('b[role="presentation"]').removeClass('ays_fa ays_fa_chevron_down'); 2050 $(this).find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_up'); 2051 } else { 2052 $(this).find('b[role="presentation"]').removeClass('ays_fa ays_fa_chevron_up'); 2053 $(this).find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down'); 2054 } 2055 }); 2056 2057 $(document).on("select2:selecting", 'select.ays-select', function(e){ 2058 $(this).parents('.ays-quiz-container').find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down'); 2059 }); 2060 2061 $(document).on("select2:opening", 'select.ays-select', function(e){ 2062 $(this).parents('.ays-quiz-container').css('z-index', 1); 2063 $(this).parents('.step').css('z-index', 1); 2064 }); 2065 2066 $(document).on("select2:closing", 'select.ays-select', function(e){ 2067 $(this).parents('.ays-quiz-container').find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down'); 2068 $(this).parents('.ays-quiz-container').css('z-index', 'initial'); 2069 $(this).parents('.step').css('z-index', 'initial'); 2070 }); 2071 2072 // $(document).find('select.ays-select').on("select2:select", function(e){ 2073 2074 // var _this = $(this); 2075 // var parentStep = _this.parents('.step'); 2076 2077 // var quizContainer = $(e.target).parents('.ays-quiz-container'); 2078 // var quizForm = quizContainer.find('form.ays-quiz-form'); 2079 // var right_answer_sound = quizContainer.find('.ays_quiz_right_ans_sound').get(0); 2080 // var wrong_answer_sound = quizContainer.find('.ays_quiz_wrong_ans_sound').get(0); 2081 // var finishAfterWrongAnswer = (myOptions.finish_after_wrong_answer && myOptions.finish_after_wrong_answer == "on") ? true : false;
2082 2083 // var explanationTime = myOptions.explanation_time && myOptions.explanation_time != "" ? parseInt(myOptions.explanation_time) : 4; 2084 2085 // myOptions.quiz_waiting_time = ( myOptions.quiz_waiting_time ) ? myOptions.quiz_waiting_time : "off"; 2086 // var quizWaitingTime = (myOptions.quiz_waiting_time && myOptions.quiz_waiting_time == "on") ? true : false; 2087 2088 // myOptions.enable_next_button = ( myOptions.enable_next_button ) ? myOptions.enable_next_button : "off"; 2089 // var quizNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == "on") ? true : false; 2090 2091 // if ( quizWaitingTime && !quizNextButton ) { 2092 // explanationTime += 2; 2093 // } 2094 2095 // var quizWaitingCountDownDate = new Date().getTime() + (explanationTime * 1000); 2096 2097 // var questionId = parentStep.attr('data-question-id'); 2098 // var selectOptions = _this.children("option[data-chisht]"); 2099 // for(var j = 0; j < selectOptions.length; j++){ 2100 // var currnetSelectOption = $(selectOptions[j]); 2101 // var answerId = currnetSelectOption.val(); 2102 2103 // if( typeof questionId != "undefined" && questionId !== null && quizForm.hasClass('enable_correction') ){ 2104 2105 // var thisQuestionCorrectAnswer = myQuizOptions[questionId].question_answer.length <= 0 ? new Array() : myQuizOptions[questionId].question_answer; 2106 // var ifCorrectAnswer = thisQuestionCorrectAnswer[answerId] == '' ? '' : thisQuestionCorrectAnswer[answerId]; 2107 // if( typeof ifCorrectAnswer != "undefined" ){ 2108 // parentStep.find('.ays-field input[data-id="'+ answerId +'"][name="ays_answer_correct[]"]').val(ifCorrectAnswer); 2109 // currnetSelectOption.attr('data-chisht', ifCorrectAnswer); 2110 // } 2111 // } 2112 // } 2113 2114 // $(this).parent().find('.ays-select-field-value').attr("value", $(this).val()); 2115 // if($(this).parents(".ays-questions-container").find('form[id^="ays_finish_quiz"]').hasClass('enable_correction')) { 2116 // var chishtPatasxan = $(this).find('option:selected').data("chisht"); 2117 // if (chishtPatasxan == 1) { 2118 // if((right_answer_sound)){ 2119 // resetPlaying([right_answer_sound, wrong_answer_sound]); 2120 // setTimeout(function(){ 2121 // right_answer_sound.play(); 2122 // }, 10); 2123 // } 2124 // $(this).parents('.ays-field').addClass('correct correct_div'); 2125 // $(this).parents('.ays-field').find('.select2-selection.select2-selection--single').css("border-bottom-color", "green"); 2126 // } else { 2127 // if((wrong_answer_sound)){ 2128 // resetPlaying([right_answer_sound, wrong_answer_sound]); 2129 // setTimeout(function(){ 2130 // wrong_answer_sound.play(); 2131 // }, 10); 2132 // } 2133 // $(this).parents('.ays-field').addClass('wrong wrong_div'); 2134 // $(this).parents('.ays-field').find('.select2-selection.select2-selection--single').css("border-bottom-color", "red"); 2135 // var rightAnswerText = '<div class="ays-text-right-answer">'+ 2136 // $(this).find('option[data-chisht="1"]').html()+ 2137 // '</div>'; 2138 // $(this).parents('.ays-quiz-answers').append(rightAnswerText); 2139 // $(this).parents('.ays-quiz-answers').find('.ays-text-right-answer').css("text-align", "left"); 2140 // $(this).parents('.ays-quiz-answers').find('.ays-text-right-answer').slideDown(500); 2141 // } 2142 // if(myOptions.answers_rw_texts && (myOptions.answers_rw_texts == 'on_passing' || myOptions.answers_rw_texts == 'on_both')){ 2143 // if (chishtPatasxan == 1) { 2144 // $(e.target).parents().eq(3).find('.right_answer_text').slideDown(500); 2145 // } else { 2146 // $(e.target).parents().eq(3).find('.wrong_answer_text').slideDown(500); 2147 // } 2148 // } 2149 // if(finishAfterWrongAnswer && chishtPatasxan != 1){ 2150 // $(e.target).parents('div[data-question-id]').find('.ays_
2150next').attr('disabled', 'disabled'); 2151 // $(e.target).parents('div[data-question-id]').find('.ays_early_finish').attr('disabled', 'disabled'); 2152 // } 2153 // explanationTimeout = setTimeout(function(){ 2154 // if (chishtPatasxan == 1) { 2155 // if ($(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && 2156 // $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) { 2157 // $(e.target).parents('div[data-question-id]').find('.ays_next').trigger('click'); 2158 // } 2159 // }else{ 2160 // if(finishAfterWrongAnswer){ 2161 // goToLastPage(e); 2162 // }else{ 2163 // if ($(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && 2164 // $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) { 2165 // $(e.target).parents('div[data-question-id]').find('.ays_next').trigger('click'); 2166 // } 2167 // } 2168 // } 2169 // }, explanationTime*1000); 2170 // if (quizWaitingTime && !quizNextButton) { 2171 // window.countdownTimeForShowInterval = setInterval(function () { 2172 // countdownTimeForShow( parentStep, quizWaitingCountDownDate ); 2173 // }, 1000); 2174 // } 2175 2176 // var showExplanationOn = (myOptions.show_questions_explanation && myOptions.show_questions_explanation != "") ? myOptions.show_questions_explanation : "on_results_page"; 2177 // if(showExplanationOn == 'on_passing' || showExplanationOn == 'on_both'){ 2178 // if(! $(this).parents('.step').hasClass('not_influence_to_score')){ 2179 // $(this).parents('.step').find('.ays_questtion_explanation').slideDown(250); 2180 // } 2181 // } 2182 2183 // $(this).attr("disabled", true); 2184 // $(e.target).next().css("background-color", "#777"); 2185 // $(e.target).next().find('.selection').css("background-color", "#777"); 2186 // $(e.target).next().find('.select2-selection').css("background-color", "#777"); 2187 // }else{ 2188 // if ($(this).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && $(this).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) { 2189 // $(this).parents('div[data-question-id]').find('.ays_next').trigger('click'); 2190 // } 2191 // } 2192 // var this_select_value = $(this).val(); 2193 // $(this).find("option").removeAttr("selected"); 2194 // $(this).find("option[value='"+this_select_value+"']").attr("selected", true); 2195 // }); 2196 2197 var shareButtons = document.querySelectorAll(".ays-share-btn.ays-to-share"); 2198 2199 if (shareButtons) { 2200 [].forEach.call(shareButtons, function(button) { 2201 button.addEventListener("click", function(event) { 2202 var width = 650, 2203 height = 450; 2204 2205 event.preventDefault(); 2206 2207 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)); 2208 }); 2209 }); 2210 } 2211 2212 $(document).find('.ays-quiz-container').map(function () { 2213 $(this).find('div[data-question-id]').eq(0).find('.ays_previous').css({'display':'none'}); 2214 var next_sibilings_count = parseInt($(this).find('.ays_question_count_per_page').val()); 2215 if(next_sibilings_count>0){ 2216 $(this).find('div[data-question-id]').eq(next_sibilings_count-1).find('.ays_previous').css({'display':'none'}); 2217 } 2218 }); 2219 2220 $(document).on('click', '.ays_finish.action-button.ays_arrow', function () { 2221 $(this).parents('.ays_buttons_div').find('input.ays_next.action-button').trigger('click'); 2222 }); 2223 2224 $(document).find('div[data-question-id]').map(function () { 2225 $(this).find('.ays-quiz-answers .ays-field').map(function () { 2226 if($(this).find('label[for^="ays-answer"]').eq(1).find('img').length !== 0){ 2227 $(this).find('label[for^="ays-answer"]').eq(0).addClass('ays_empty_before_content'); 2228 if($(this).find('label[for^="ays-answer"]').eq(0).text().length === 0){ 2229 $(this).find('label[for^="ays-answer"]').eq(0).css('background','transparent'); 2230 } 2231 } 2232 }); 2233 }); 2234 2235 $(document).on('click', '.ays_finish.action-button', function () { 2236 var quizId = $(this).parents(".ays-quiz-container").find('input[name="ays_quiz_id"]').val(); 2237 if ( typeof window.aysEarlyFinishConfirmBox != 'undefined') { 2238 if ( typeof window.aysEarlyFinishConfirmBox[ quizId ] != 'undefined' ) { 2239 if( window.aysSeeResultConfirmBox[ quizId ] == true ){ 2240 $(this).addClass("ays_timer_end"); 2241 } 2242 } 2243 } 2244 if (typeof $(this).parents('.ays-quiz-container').find('.ays_
2244next.start_button').attr("data-enable-leave-page") !== 'undefined') { 2245 if(! $(this).parents('.ays-quiz-container').find('.step.active-step .ays-abs-fs.ays-end-page').hasClass('information_form')){ 2246 $(this).parents('.ays-quiz-container').find('.ays_next.start_button').attr("data-enable-leave-page",false); 2247 } 2248 } 2249 }); 2250 2251 $(document).on('click', '.ays_early_finish.action-button', function (e) { 2252 e.preventDefault(); 2253 var quizId = $(this).parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val(); 2254 2255 myOptions.enable_early_finsh_comfirm_box = ! myOptions.enable_early_finsh_comfirm_box ? 'on' : myOptions.enable_early_finsh_comfirm_box; 2256 var enable_early_finsh_comfirm_box = (myOptions.enable_early_finsh_comfirm_box && myOptions.enable_early_finsh_comfirm_box == 'on') ? true : false; 2257 if (enable_early_finsh_comfirm_box) { 2258 var confirm = window.confirm(quizLangObj.areYouSure); 2259 }else{ 2260 var confirm = true; 2261 } 2262 if(confirm){ 2263 clearTimeout(explanationTimeout); 2264 window.aysEarlyFinishConfirmBox[ quizId ] = true; 2265 var totalSteps = $(e.target).parents().eq(3).find('div.step').length; 2266 var currentStep = $(e.target).parents().eq(3).find('div.step.active-step'); 2267 var thankYouStep = $(e.target).parents().eq(3).find('div.step.ays_thank_you_fs'); 2268 var infoFormLast = thankYouStep.prev().find('div.information_form'); 2269 var questions_count = $(e.target).parents('form').find('div[data-question-id]').length; 2270 $(this).parents('.ays-quiz-container').find('.ays_finish.action-button').addClass("ays_timer_end"); 2271 if (typeof $(this).parents('.ays-quiz-container').find('.ays_next.start_button').attr("data-enable-leave-page") !== 'undefined') { 2272 if(! $(this).parents('.ays-quiz-container').find('.step .ays-abs-fs.ays-end-page').hasClass('information_form')){ 2273 $(this).parents('.ays-quiz-container').find('.ays_next.start_button').attr("data-enable-leave-page",false); 2274 } 2275 } 2276 if($(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ 2277 $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(questions_count); 2278 }else{ 2279 $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({ 2280 width: '100%' 2281 }); 2282 $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(100); 2283 } 2284 currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').slideUp(); 2285 setTimeout(function () { 2286 currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').parent().hide(); 2287 },300); 2288 if(infoFormLast.length == 0){ 2289 if (currentStep.hasClass('ays_thank_you_fs') === false) { 2290 var steps = totalSteps - 3; 2291 $(e.target).parents().eq(3).find('div.step').each(function (index) { 2292 if ($(this).hasClass('ays_thank_you_fs')) { 2293 $(this).addClass('active-step') 2294 }else{ 2295 $(this).css('display', 'none'); 2296 } 2297 }); 2298 $(e.target).parents().eq(3).find('input.ays_finish').trigger('click'); 2299 } 2300 }else{ 2301 currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').parent().hide(); 2302 $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut'); 2303 setTimeout(function () { 2304 $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none'); 2305 },300); 2306 aysAnimateStep($(e.target).parents('.ays-quiz-container').data('quest-effect'), currentStep, infoFormLast.parent()); 2307 $(e.target).parents().eq(3).find('div.step').each(function (index) { 2308 $(this).css('display', 'none'); 2309 $(this).removeClass('active-step') 2310 }); 2311 infoFormLast.parent().css('display', 'flex'); 2312 infoFormLast.parent().addClass('active-step'); 2313 } 2314 } 2315 }); 2316 2317 2318 $(document).on('click', '.action-button.ays_restart_training_button', function () { 2319 window.location.href = window.location.href + ( window.location.search ? '&' : '?' ) + 'reset_quiz=1'; 2320 }); 2321 2322 $(document).on('click', '.action-button.ays_restart_button', function () { 2323 window.location.reload(); 2324 }); 2325 2326 $(document).on('click', '.action-button.ays_clear_answer', function () { 2327 var $this = $(this); 2328 var activeStep = $this.parents('.step'); 2329 var inputs = activeStep.find('input[name^="ays_questions[ays-question-"]:checked'); 2330 var checked_answer_divs = activeStep.find('div.ays-field.checked_answer_div'); 2331 var ays_text_field = activeStep.find('div.ays-field.ays-text-field'); 2332 var ays_select_field = activeStep.find('div.ays-field.ays-select-field'); 2333 checked_answer_divs.removeClass('checked_answer_div'); 2334 ays_text_field.find('.ays-text-input').val(''); 2335 if(ays_select_field.find('select.ays-select').length > 0){ 2336 ays_select_field.find('select.ays-select').val(null).trigger('change'); 2337 } 2338 inputs.removeAttr('checked'); 2339 }); 2340 2341 $(document).on('click', '.ays_music_sound', function() { 2342 var $this = $(this); 2343 var quizCoutainer = $this.parents('.ays-quiz-container'); 2344 var audioEls = $(document).find('.ays_quiz_music'); 2345 var soundEls = $(document).find('.ays_music_sound'); 2346 var audioEl = quizCoutainer.find('.ays_quiz_music').get(0); 2347 if($this.hasClass('ays_sound_active')){ 2348 audioEl.volume = 0; 2349 $this.find('.ays_fa').addClass('ays_fa_volume_off').removeClass('ays_fa_volume_up'); 2350 $this.removeClass('ays_sound_active'); 2351 } else { 2352 audioEl.volume = 1; 2353 $this.find('.ays_fa').addClass('ays_fa_volume_up').removeClass('ays_fa_volume_off'); 2354 $this.addClass('ays_sound_active'); 2355 } 2356 }); 2357 2358 function ays_formatState (ays_state) { 2359 if(!ays_state.id) { 2360 return aysEscapeHtml(ays_state.text); 2361 } 2362 var baseUrl = $(ays_state.element).data('nkar'); 2363 if(baseUrl != ''){ 2364 var ays_state = $( 2365 '<span><img src=' + baseUrl + ' class="ays_answer_select_image" /> ' + aysEscapeHtml(ays_state.text) + '</span>' 2366 ); 2367 }else{ 2368 var ays_state = $('<span>' + aysEscapeHtml(ays_state.text) + '</span>'); 2369 } 2370 return ays_state; 2371 } 2372 2373 $(document).find('.ays-quiz-container').each(function(){ 2374 var $this = $(this); 2375 var selectEl = $this.find('select.ays-select'); 2376 selectEl.each(function(){ 2377 $(this).select2({ 2378 placeholder: quizLangObj.selectPlaceholder, 2379 dropdownParent: $(this).parents('.ays-abs-fs'), 2380 templateResult: ays_formatState 2381 }); 2382 }); 2383 }); 2384 2385 $(document).find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down'); 2386 2387 function aysResetQuiz ($quizContainer){ 2388 var cont = $quizContainer.find('div[data-question-id]'); 2389 cont.find('input[type="text"], textarea, input[type="number"], input[type="url"], input[type="email"]').each(function(){ 2390 $(this).val(''); 2391 }); 2392 cont.find('select').each(function(){ 2393 $(this).val(''); 2394 }); 2395 cont.find('select.ays-select').each(function(){ 2396 $(this).val(null).trigger('change'); 2397 }); 2398 cont.find('select option').each(function(){ 2399 $(this).removeAttr('selected'); 2400 }); 2401 cont.find('input[type="radio"], input[type="checkbox"]').each(function(){ 2402 $(this).removeAttr('checked'); 2403 }); 2404 } 2405 2406 window.onbeforeunload = function (e) { 2407 var startButton = $(document).find('.ays-quiz-container .ays_next.start_button'); 2408 var flag = false;
2409 for (var i = 0; i < startButton.length; i++) { 2410 var startBtn = startButton.eq(i).attr('data-enable-leave-page'); 2411 if(typeof startBtn != undefined && startBtn === 'true'){ 2412 flag = true; 2413 break; 2414 } 2415 } 2416 2417 if(flag){ 2418 return true; 2419 }else{ 2420 return null; 2421 } 2422 } 2423 2424 $(document).find('.ays_next.start_button.ays_quiz_enable_loader').each(function(e){ 2425 var $this = $(this); 2426 var container = $(this).parents('.ays-quiz-container'); 2427 2428 var ays_quiz = setInterval( function() { 2429 if (document.readyState === 'complete') { 2430 var startButtonText = quizLangObj.startButtonText; 2431 if (startButtonText == null || startButtonText == '' ) { 2432 startButtonText = quizLangObj.defaultStartButtonText; 2433 } 2434 2435 container.find('.ays_quiz_start_button_loader').addClass('ays_display_none'); 2436 if ( $this.hasClass('ays_quiz_enable_loader') ) { 2437 $this.removeClass('ays_quiz_enable_loader'); 2438 } 2439 2440 var passwordQuizInput = container.find("input.ays_quiz_password"); 2441 if(passwordQuizInput.length > 0){ 2442 $this.prop('disabled', true); 2443 } else { 2444 $this.prop('disabled', false); 2445 } 2446 2447 $this.val( startButtonText ); 2448 clearInterval(ays_quiz); 2449 } 2450 } , 500); 2451 }); 2452 2453 $(document).find('.show_timer_countdown').each(function(e){ 2454 // Countdown date 2455 var countDownEndDate = $(this).data('timer_countdown'); 2456 var quiz_id = $(this).parents(".ays-quiz-container").attr("id"); 2457 if (countDownEndDate != '' && countDownEndDate != undefined) { 2458 var showM = $(this).parents('.step').data('messageExist'); 2459 ays_countdown_datetime(countDownEndDate, !showM , quiz_id); 2460 } 2461 }); 2462 2463 function toggleFullscreen(elem) { 2464 elem = elem || document.documentElement; 2465 if (!document.fullscreenElement && !document.mozFullScreenElement && 2466 !document.webkitFullscreenElement && !document.msFullscreenElement) { 2467 aysQuizFullScreenActivate( elem ); 2468 if (elem.requestFullscreen) { 2469 elem.requestFullscreen(); 2470 }else if (elem.msRequestFullscreen) { 2471 elem.msRequestFullscreen(); 2472 }else if (elem.mozRequestFullScreen) { 2473 elem.mozRequestFullScreen(); 2474 }else if (elem.webkitRequestFullscreen) { 2475 elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); 2476 } 2477 }else{ 2478 aysQuizFullScreenDeactivate( elem ); 2479 if(document.exitFullscreen) { 2480 document.exitFullscreen(); 2481 }else if (document.msExitFullscreen) { 2482 document.msExitFullscreen(); 2483 }else if (document.mozCancelFullScreen) { 2484 document.mozCancelFullScreen(); 2485 }else if (document.webkitExitFullscreen) { 2486 document.webkitExitFullscreen(); 2487 } 2488 } 2489 } 2490 2491 function aysQuizFullScreenActivate( elem ){ 2492 $(elem).find('.ays-quiz-full-screen-container > .ays-quiz-close-full-screen').css({'display':'block'}); 2493 $(elem).find('.ays-quiz-full-screen-container > .ays-quiz-open-full-screen').css('display','none'); 2494 //$(elem).find('.step:not(:first-of-type,.ays_thank_you_fs)').css({'height':'100vh'}); 2495 $(elem).css({'overflow':'auto'}); 2496 2497 if( $(elem).find('.ays_quiz_reports').length > 0 ){ 2498 $(elem).find('.ays_quiz_reports').css({ 2499 'position': 'fixed', 2500 'z-index': '1', 2501 }); 2502 }else{ 2503 if( $(elem).find('.ays_quiz_rete_avg').length > 0 ){ 2504 $(elem).find('.ays_quiz_rete_avg').css({ 2505 'position': 'fixed', 2506 'z-index': '1', 2507 }); 2508 } 2509 2510 if( $(elem).find('.ays_quizn_ancnoxneri_qanak').length > 0 ){ 2511 $(elem).find('.ays_quizn_ancnoxneri_qanak').css({ 2512 'position': 'fixed', 2513 'z-index': '1', 2514 }); 2515 } 2516 } 2517 } 2518 2519 function aysQuizFullScreenDeactivate( elem ){ 2520 $(elem).find('.ays-quiz-full-screen-container > svg.ays-quiz-open-full-screen').css({'display':'block'}); 2521 $(elem).find('.ays-quiz-full-screen-container > svg.ays-quiz-close-full-screen').css('display','none'); 2522 //$(elem).find('.step:not(:first-of-type)').css({'height':'auto'}); 2523 $(elem).css({'overflow':'initial'}); 2524 2525 if( $(elem).find('.ays_quiz_reports').length > 0 ){ 2526 $(elem).find('.ays_quiz_reports').css({ 2527 'position': 'absolute', 2528 'z-index': '1', 2529 }); 2530 }else{ 2531 if( $(elem).find('.ays_quiz_rete_avg').length > 0 ){ 2532 $(elem).find('.ays_quiz_rete_avg').css({ 2533 'position': 'absolute', 2534 'z-index': '1', 2535 }); 2536 } 2537 2538 if( $(elem).find('.ays_quizn_ancnoxneri_qanak').length > 0 ){ 2539 $(elem).find('.ays_quizn_ancnoxneri_qanak').css({ 2540 'position': 'absolute', 2541 'z-index': '1', 2542 }); 2543 } 2544 } 2545 } 2546 2547 document.addEventListener('fullscreenchange', function(event) { 2548 if (!document.fullscreenElement) { 2549 var eventTarget = event.target 2550 if( $( eventTarget ).hasClass('ays-quiz-container') ){ 2551 aysQuizFullScreenDeactivate( eventTarget ); 2552 } 2553 } 2554 }, false); 2555 2556 $(document).on('click', '.ays-quiz-open-full-screen, .ays-quiz-close-full-screen', function() { 2557 var quiz_container = $(this).parents('.ays-quiz-container').get(0); 2558 toggleFullscreen(quiz_container); 2559 }); 2560 2561 $(document).on('change', '.ays-quiz-res-toggle-checkbox', function(){ 2562 var _this = $(this); 2563 var parent = _this.parents('.ays_quiz_results'); 2564 var elements = parent.find('.step.ays_question_result'); 2565 2566 if (_this.prop('checked')) { 2567 if ( elements.hasClass('ays_display_none') ) { 2568 elements.removeClass('ays_display_none'); 2569 } 2570 }else{ 2571 elements.addClass('ays_display_none'); 2572 } 2573 }); 2574 2575 $(document).on('keydown', function(e) { 2576 var keyboardBox = $(document).find(".ays-quiz-container.ays-quiz-keyboard-active"); 2577 2578 if(e.keyCode === 9 && keyboardBox.length > 0){ 2579 $(document).find(".ays-select-field *:not(.dropdown-wrapper,.select2-selection__arrow, .select2-selection__placeholder, .ays_fa.ays_fa_chevron_down)").attr("tabindex" , "0") 2580 } 2581 2582 if(e.keyCode === 27){ 2583 var zoomPopup = $(document).find('.ays-quiz-question-image-lightbox-container'); 2584 if( zoomPopup.length > 0 ){ 2585 zoomPopup.hide(); 2586 } 2587 2588 var questionReportPopup = $(document).find('div[id*="ays-quiz-question-report-modal"]'); 2589 if( questionReportPopup.length > 0 ){ 2590 questionReportPopup.hide(); 2591 } 2592 } 2593 2594 if($(e.target).hasClass("ays-quiz-keyboard-active")){ 2595 if (e.keyCode === 32) { 2596 e.preventDefault(); 2597 $(e.target).find('label.ays-quiz-keyboard-label').trigger("click"); 2598 } 2599 2600 2601 if (e.keyCode === 13) { 2602 e.preventDefault(); 2603 var checked_inputs = $(e.target).parents(".ays-quiz-answers").find('input
2603:checked'); 2604 if(checked_inputs.length > 0){ 2605 $(e.target).parents('.step.active-step').find(".ays_next").trigger('click'); 2606 } 2607 else{ 2608 $(e.target).trigger('click'); 2609 } 2610 2611 } 2612 } 2613 }); 2614 2615 $(document).on('click', '.ays-image-question-img .ays-quiz-question-image-zoom', function() { 2616 var _this = $(this); 2617 2618 var dataSrc = _this.attr('data-ays-src'); 2619 2620 if (dataSrc != null && dataSrc != "") { 2621 var aysImagesOverlayBox = $(document).find('.ays-quiz-question-image-lightbox-container'); 2622 var lightboxContainer = ""; 2623 if (aysImagesOverlayBox.length > 0 ) { 2624 var mainDiv = document.querySelector(".ays-quiz-question-image-lightbox-container"); 2625 var createdImgTag = document.querySelector(".ays-quiz-question-image-lightbox-img"); 2626 2627 createdImgTag.src = dataSrc; 2628 mainDiv.style.display = "flex"; 2629 } else { 2630 var bodyTag = document.getElementsByTagName("body")[0]; 2631 2632 lightboxContainer += '<div class="ays-quiz-question-image-lightbox-container" style="display: flex;">'; 2633 2634 lightboxContainer += '<div class="ays-quiz-question-image-lightbox-img-box">'; 2635 lightboxContainer += '<img class="ays-quiz-question-image-lightbox-img" src="'+ dataSrc +'" style="z-index: 102;">'; 2636 lightboxContainer += '</div>'; 2637 lightboxContainer += '<span class="ays-quiz-question-image-lightbox-close-button">Ã</span>'; 2638 2639 lightboxContainer += '</div>'; 2640 2641 $(document).find('html > body').append(lightboxContainer); 2642 2643 var mainDiv = $(document).find(".ays-quiz-question-image-lightbox-container"); 2644 mainDiv.css({ 2645 'display': 'flex' 2646 }); 2647 } 2648 } 2649 }); 2650 2651 2652 $(document).on('click', '.ays-quiz-question-image-lightbox-close-button', function() { 2653 var _this = $(this); 2654 var parent = _this.parents(".ays-quiz-question-image-lightbox-container"); 2655 2656 parent.css({ 2657 'display': 'none' 2658 }); 2659 }); 2660 2661 $(document).on('click', '.ays-quiz-question-image-lightbox-container', function(e){ 2662 var modalBox = $(e.target).attr('class'); 2663 var _this = $(this); 2664 2665 if (typeof modalBox != 'undefined' && modalBox == 'ays-quiz-question-image-lightbox-container') { 2666 _this.css({ 2667 'display': 'none' 2668 }); 2669 } 2670 }); 2671 2672 $(document).on('click', '.ays-quiz-open-report-window', function() { 2673 var _this = $(this); 2674 var parent = _this.parents('div.ays-quiz-container'); 2675 2676 if (_this.parents('div.step.active-step').length > 0) { 2677 var question = _this.parents('div.step.active-step'); 2678 } else { 2679 var question = _this.parents('div.step.ays_question_result'); 2680 2681 } 2682 2683 if( question.length == 0 ){ 2684 var question = _this.parents('div.step'); 2685 } 2686 2687 var questionId = question.attr('data-question-id'); 2688 2689 var reportsModal = parent.find('div.ays-modal-reports'); 2690 2691 reportsModal.fadeIn(200, function() { 2692 reportsModal.find('textarea#ays-quiz-question-report-textarea').val(''); 2693 reportsModal.find('input.ays-quiz-report-question-id').val(questionId); 2694 }); 2695 }); 2696 2697 $(document).on('click', '.ays-close-reports-window', function() { 2698 var _this = $(this); 2699 var parent = _this.parents('div.ays-quiz-container'); 2700 var reportsModal = parent.find('div.ays-modal-reports'); 2701 2702 reportsModal.fadeOut(200); 2703 }); 2704 2705 $(document).on('click', '.information_form .ays_next.action-button', function(e){ 2706 var infoFormStep = $(this).parents('.step'); 2707 var previousStepHasStartButton = infoFormStep.prev().find('.ays_
2707next.start_button').length !== 0; 2708 2709 if (previousStepHasStartButton && $(this).hasClass('ays_start_allow')) { 2710 time_limit.call(this, e); 2711 } 2712 }); 2713 2714 $(document).off('click.aysQuizPreviewNoticeCopy').on('click.aysQuizPreviewNoticeCopy', '.ays-quiz-preview-copy-shortcode', function(e){ 2715 e.preventDefault(); 2716 aysQuizCopyPreviewShortcode( $(this) ); 2717 }); 2718 }); 2719 2720})( 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.