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cAAe,CACvCE,cAAe,EACfC,aAAc,GACdC,eAAe,EACfC,eAAe,EACfC,MAAM,EACNC,WAAY,CACVC,OAAQ/C,SAASM,cAAc,mDAC/B0C,OAAQhD,SAASM,cAAc,oDAEjC2C,YAAa,CACX,IAAK,CACHR,cAAe,EACfC,aAAc,MAKxB,EACAQ,KAAM,WACQtC,KAENb,UAFMa,KAGNS,yBAHMT,KAINgB,0BAJMhB,KAKN0B,kBACR,GAGFzC,OAAOU,iBAAiB,oBAAoB,KAC1CT,SAASoD,MAAM","sources":["webpack://build/../barrocaneon/assets/javascripts/quiz.js"],"sourcesContent":["window.quizPage = {\n setQuiz: function(){\n // Remove a seleção de todos os itens;\n const inputs = document.querySelectorAll('input[type=\"radio\"]');\n\n inputs.forEach( input => {\n input.checked = false;\n })\n\n // Seleciona form\n const quizForm = document.querySelector('.quiz-form');\n\n if(quizForm){\n quizForm.addEventListener('submit', function(e){\n e.preventDefault();\n // Coleta os dados preenchidos no form para montagem da url\n const formData = new FormData(this);\n let url = ['/p/quiz-resultado?'];\n let href;\n\n // Adiciona os itens dentro da variavel url\n for(var pair of formData.entries()) {\n url.push(pair[0]+ '='+ pair[1]);\n url.push('&')\n }\n\n // Termina de estruturar a url\n url.pop();\n href = url.join('');\n\n // Navega para a página com o produto referente ao resultado\n window.location.href = href;\n })\n }\n },\n setMultiplePaddingTops: function(){\n const headerCta = document.querySelector('[data-header-cta]');\n const headerCtaMobile = document.querySelector('[data-header-cta-mobile]');\n const HTML = document.querySelector('html');\n\n if(headerCta){\n headerCta.addEventListener('click', function(){\n HTML.style.scrollPaddingTop = '100px';\n\n setTimeout(() => {\n HTML.style.scrollPaddingTop = '60vh';\n }, 500)\n })\n }\n\n if(headerCtaMobile){\n headerCtaMobile.addEventListener('click', function(){\n HTML.style.scrollPaddingTop = '140px';\n\n setTimeout(() => {\n HTML.style.scrollPaddingTop = '37vh';\n }, 500)\n })\n }\n },\n setScrollToNextQuestion: function(){\n const answers = document.querySelectorAll('.answers');\n \n if(answers){\n answers.forEach( (answer, index) => {\n const options = answer.querySelectorAll('input');\n\n options.forEach(option => {\n option.addEventListener('change', function(){\n\n if( index < (answers.length - 1) ){\n document.querySelector(`#question-${index + 2}`).scrollIntoView();\n } else{\n window.scrollBy({\n top: 330,\n behavior: 'smooth'\n })\n }\n })\n })\n })\n }\n },\n setSwiperRelated: function(){\n const swiperRelated = document.querySelector('[data-related-slider]');\n\n if(swiperRelated){\n const swiper = new Swiper(swiperRelated, {\n slidesPerView: 2,\n spaceBetween: 20,\n watchOverflow: true,\n simulateTouch: false,\n loop: false,\n navigation: {\n nextEl: document.querySelector('.product-related .container .swiper-button-next'),\n prevEl: document.querySelector('.product-related .container .swiper-button-prev'),\n },\n breakpoints: {\n 768: {\n slidesPerView: 3,\n spaceBetween: 25,\n }\n }\n });\n }\n },\n init: function(){\n var _this = this;\n\n _this.setQuiz();\n _this.setMultiplePaddingTops();\n _this.setScrollToNextQuestion();\n _this.setSwiperRelated();\n }\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n quizPage.init();\n})"],"names":["window","quizPage","setQuiz","document","querySelectorAll","forEach","input","checked","quizForm","querySelector","addEventListener","e","preventDefault","formData","FormData","this","href","url","pair","entries","push","pop","join","location","setMultiplePaddingTops","headerCta","headerCtaMobile","HTML","style","scrollPaddingTop","setTimeout","setScrollToNextQuestion","answers","answer","index","option","length","scrollIntoView","scrollBy","top","behavior","setSwiperRelated","swiperRelated","Swiper","slidesPerView","spaceBetween","watchOverflow","simulateTouch","loop","navigation","nextEl","prevEl","breakpoints","init"],"sourceRoot":""}