$(function(){ function setSubmitted() { $('#submittalents').attr('disabled', 'disabled'); $('#submittalents').text($('#submittalents').attr('data-label-submitted')); $('#submittalents').trigger('manualclick'); $('#build-target').addClass('respondents-submitted'); $('#talents-resultcontainer').find('.talent-item'); userMessage($('#submittalents').attr('text-respondents-submitted')); } function userMessage(message) { if (!!message) {console.error(message); openAlertModal(); $('#alert-message').text(message); } else console.error('undefined usermessage requested'); } $('#submittalents').click(function(){ var valid=true; // first, check number of checked talents var talentcount=$('#talents-resultcontainer').find('.answer-checkbox:checked').length; var respondentcount=($('#respondent-selection').data('json')||[]).length; console.log('talents chosen: '+talentcount+', respondends entered: '+respondentcount); var reason; if (talentcount < window.talents.min || talentcount > window.talents.max) { valid=false; if (talentcount < window.talents.min) reason=$(this).attr('text-talents-notenough'); else reason=$(this).attr('text-talents-toomany'); } if (valid && (respondentcount< window.respondents.min | respondentcount > window.respondents.max )) { valid=false; if (respondentcount < window.respondents.min) reason=$(this).attr('text-respondents-notenough'); else reason=$(this).attr('text-respondents-toomany'); } if (valid) { setSubmitted(); } else userMessage(reason); }); function openAlertModal() { alertTL.play().timeScale(1); } function closeAlertModal() { alertTL.reverse().timeScale(-2) $('html').removeClass('no-scroll'); } $('#alert-back').on('click',function(){ closeAlertModal(); }); const alertTL = gsap.timeline({paused: true}); alertTL.to($('#alert-modal'), { duration: .6, ease: Power4.easeOut, autoAlpha: 1, onStart: function () { $('html').addClass('no-scroll'); }, }); alertTL.from($('#alert-modal .modal-content'), { delay: -.3, duration: .6, ease: Power4.easeOut, autoAlpha: 0, y: '0px', }); }); /*******************************************************************/ /* ftrtch dino */ /* [type: JS] [file:main-i-submit] [165.3918] DESIGN*/ /*******************************************************************/ /* 0.4 D>D */ /* db 191 */