1var brave_isMobile=window.matchMedia("only screen and (max-width: 760px)").matches;var brave_isTab=window.matchMedia("screen and (max-width: 1200px) and (min-width: 760px)").matches;var brave_currentDevice=brave_isMobile?'mobile':'desktop';var brave_back_pressed=0;function brave_number_padding(num){if(num){var theNum=parseInt(num,10);return theNum<10?parseInt("0"+theNum,10):theNum}} 2function brave_change_slide(elementID,goto,slideWidth){var sliderMargin=-(goto*slideWidth)+'px' 3var theCarousel=document.getElementById('brave_carousel__slides-'+elementID);var theCarouselNav=document.getElementById('brave_carousel__navs-'+elementID);if(theCarousel){theCarousel.style.marginLeft=sliderMargin;if(theCarouselNav){var allCarouselNavs=theCarouselNav.querySelectorAll(":scope li");for(var i=0;i<allCarouselNavs.length;i++){allCarouselNavs[i].classList.remove('slide__nav__active')} 4document.getElementById('brave_carousel__nav-'+elementID+'_'+goto).classList.add('slide__nav__active')}}} 5function brave_autochange_slide(elementID){var theSlider=document.getElementById('brave_carousel__slides-'+elementID);var currentslide=document.querySelector('#brave_carousel__navs-'+elementID).dataset.currentslide;currentslide=parseInt(currentslide,10) 6var slideWidth=parseInt(theSlider.dataset.width,10);var totalSlides=parseInt(theSlider.dataset.totalslides,10);var carouselHovered=theSlider.dataset.hovered;if(carouselHovered==='true'){return} 7brave_change_slide(elementID,currentslide,slideWidth);if(totalSlides===(currentslide+1)){document.querySelector('#brave_carousel__navs-'+elementID).dataset.currentslide=0}else{document.querySelector('#brave_carousel__navs-'+elementID).dataset.currentslide=currentslide+1}} 8function brave_carousel_pause(elementID,resume=!1){var theSlider=document.getElementById('brave_carousel__slides-'+elementID);if(theSlider){theSlider.dataset.hovered=!0;if(resume){theSlider.dataset.hovered=!1}}} 9function brave_toggle_item(elementID,itemClass){var theToggleElm=document.getElementById('brave_carousel__slides-'+elementID);var selectedItem=theToggleElm.getElementsByClassName(itemClass);var allToggleDesc=theToggleElm.querySelectorAll('bravepopup_carousel__slide__content');for(var i=0;i<allToggleDesc.length;i++){allToggleDesc[i].classList.remove('brave__toggle__active')} 10if(selectedItem[0]){if(selectedItem[0].classList.contains('brave__toggle__active')){selectedItem[0].classList.remove('brave__toggle__active')}else{selectedItem[0].classList.add('brave__toggle__active')}}} 11function brave_countdown(elementID,theDate,theHour,theMins,hideDays,hideHours,auto=null){if(!theDate){return null} 12var dateString=theDate;var time={hour:theHour,minutes:theMins};var brave_endDate;if(!auto){var parts=dateString.split('/');var brave_day=parseInt(parts[0],10);var brave_month=parseInt(parts[1],10)-1;var brave_year=parseInt(parts[2],10);brave_endDate=new Date(brave_year,brave_month,brave_day);brave_endDate.setHours(time.hour);brave_endDate.setMinutes(time.minutes);brave_endDate.setSeconds(0)}else{if(auto){brave_endDate=auto}} 13var brave_startDate=new Date().getTime();var brave_days,brave_hours,brave_minutes,brave_seconds;var timeRemaining=parseInt(((brave_endDate.getTime()-brave_startDate)/1000),10);if(timeRemaining>=0){if(!hideDays){brave_days=parseInt(timeRemaining/86400);timeRemaining=(timeRemaining%86400)} 14if(!hideHours){brave_hours=parseInt(timeRemaining/3600);timeRemaining=(timeRemaining%3600)} 15brave_minutes=parseInt(timeRemaining/60);timeRemaining=(timeRemaining%60);brave_seconds=parseInt(timeRemaining)} 16var daySpan=document.getElementById('brave_rem_days-'+elementID);var hourSpan=document.getElementById('brave_rem_hours-'+elementID);var minSpan=document.getElementById('brave_rem_minutes-'+elementID);var secSpan=document.getElementById('brave_rem_seconds-'+elementID);if(daySpan){daySpan.innerHTML=timeRemaining>=0?brave_days:0} 17if(hourSpan){hourSpan.innerHTML=timeRemaining>=0?brave_hours:0} 18if(minSpan){minSpan.innerHTML=timeRemaining>=0?brave_minutes:0} 19if(secSpan){secSpan.innerHTML=timeRemaining>=0?brave_seconds:0}} 20function brave_check_field_condition(event,fieldID,formID,fieldType='input'){var brave_form_conditions=brave_popup_formData&&brave_popup_formData[formID]&&brave_popup_formData[formID].conditionsMatch||{};var brave_form_cond_vals=brave_popup_formData&&brave_popup_formData[formID]&&brave_popup_formData[formID].conditionsVals||{};var conditionRules=brave_popup_formData&&brave_popup_formData[formID]&&brave_popup_formData[formID].conditions||{};var inputData=event.target.value;if(fieldType==='checkbox'){inputData='';var checkBoxes=document.querySelectorAll('#brave_form_field'+fieldID+' input');for(var index=0;
20index<checkBoxes.length;index++){var checkBoxDom=checkBoxes[index];if(!inputData&&checkBoxDom.checked){inputData=checkBoxDom.value}}} 21conditionRules.forEach(function(fieldCondition){var fieldKey=fieldCondition.field;var depKey=fieldCondition.fieldDependent;if(fieldKey===fieldID&&brave_form_conditions[depKey]){if(inputData&&fieldCondition.action==='exist'&&!brave_form_conditions[depKey][fieldKey]){brave_form_conditions[depKey][fieldKey]=!0} 22if(!inputData&&fieldCondition.action==='exist'&&brave_form_conditions[depKey][fieldKey]){brave_form_conditions[depKey][fieldKey]=!1} 23if(fieldCondition.action==='equal'&&(inputData&&(brave_form_cond_vals[depKey][fieldKey].includes(inputData)))){brave_form_conditions[depKey][fieldKey]=!0} 24if(fieldCondition.action==='equal'&&(!inputData||(!brave_form_cond_vals[depKey][fieldKey].includes(inputData)))){brave_form_conditions[depKey][fieldKey]=!1} 25if(fieldCondition.action==='notequal'&&(inputData&&(!brave_form_cond_vals[depKey][fieldKey].includes(inputData)))&&!brave_form_conditions[depKey][fieldKey]){brave_form_conditions[depKey][fieldKey]=!0} 26if(fieldCondition.action==='notequal'&&(!inputData||(brave_form_cond_vals[depKey][fieldKey].includes(inputData)))&&brave_form_conditions[depKey][fieldKey]){brave_form_conditions[depKey][fieldKey]=!1}}});Object.keys(brave_form_conditions).forEach(function(fieldKey){var matchArray=Object.keys(brave_form_conditions[fieldKey]);var matchedConditionsArray=matchArray.filter(function(depKey){if(brave_form_conditions[fieldKey][depKey]){return!0}else{return!1}}) 27var allMatched=matchedConditionsArray.length===matchArray.length;var dependantField=document.getElementById('brave_form_field'+fieldKey);if(dependantField){if(allMatched){dependantField.classList.remove('brave_form_field--hasCondition')}else{dependantField.classList.add('brave_form_field--hasCondition')} 28var formFieldsWrapper=document.querySelector('#brave_form_'+formID+' .brave_form_fields');var currentFormStep=formFieldsWrapper.dataset.step||undefined;if(currentFormStep!==undefined&&document.querySelector('#brave_form_'+formID+' .brave_form_fields .brave_form_fields_step'+currentFormStep)){formFieldsWrapper.style.height=document.querySelector('#brave_form_'+formID+' .brave_form_fields .brave_form_fields_step'+currentFormStep).offsetHeight+'px'}}})} 29function brave_select_imageField(fieldID,optionIndex,multi=!1){var optionField=document.getElementById('brave_form_field'+fieldID+'_opt-'+optionIndex);if(optionField){if(!multi){var allOptsFields=document.getElementById('brave_form_field'+fieldID).querySelectorAll('input');for(var i=0;i<allOptsFields.length;i++){allOptsFields[i].checked=!1;document.getElementById('brave_form_field'+fieldID+'_opt-'+i).classList.remove('formfield__inner__image--selected')}} 30var optionFieldInput=optionField.querySelector('input');if(optionFieldInput&&(optionFieldInput.checked===!1)){optionFieldInput.checked=!0;optionField.classList.add('formfield__inner__image--selected')}else if(optionFieldInput&&(optionFieldInput.checked===!0)){optionFieldInput.checked=!1;optionField.classList.remove('formfield__inner__image--selected')}}} 31function brave_select_form_ButtonGroup(fieldID,optionIndex,nextStep=!1,formID='',totalSteps=0,goto=undefined){brave_select_imageField(fieldID,optionIndex,!1);if(nextStep&&formID&&totalSteps&&goto!==undefined){brave_form_gotoStep(formID,totalSteps,goto)}} 32function brave_form_rating_unhover(fieldID){var allRatingFields=document.getElementById('brave_form_field'+fieldID).querySelectorAll('.formfield__inner__ratings_star, .formfield__inner__ratings_number');for(var i=0;i<allRatingFields.length;i++){allRatingFields[i].classList.remove('formfield__inner__ratings--hovered')}} 33function brave_form_rating_hover(fieldID,optionIndex){var allRatingFields=document.getElementById('brave_form_field'+fieldID).querySelectorAll('.formfield__inner__ratings_star, .formfield__inner__ratings_number');for(var i=0;i<allRatingFields.length;i++){allRatingFields[i].classList.remove('formfield__inner__ratings--hovered');if(i<=(optionIndex-1)){allRatingFields[i].classList.add('formfield__inner__ratings--hovered')}}} 34function brave_form_rate(fieldID,optionIndex,smiley=!1){document.getElementById('brave_form_field'+fieldID).dataset.rated=optionIndex;var allRatingFields=document.getElementById('brave_form_field'+fieldID).querySelectorAll('.formfield__inner__ratings_star, .formfield__inner__ratings_number, .formfield__inner__ratings_smiley');for(var i=0;i<allRatingFields.length;i++){allRatingFields[i].classList.remove('formfield__inner__ratings--selected');if(!smiley&&(i<=(optionIndex-1))){allRatingFields[i].querySelector('input').checked=!0;allRatingFields[i].classList.add('formfield__inner__ratings--selected')} 35if(smiley&&(i===(optionIndex-1))){allRatingFields[i].querySelector('input').checked=!0;allRatingFields[i].classList.add('formfield__inner__ratings--selected')}}} 36function brave_form_progress(formID,goto=0,totalSteps=2){if(document.querySelector('#'+formID+'__form_progress')){var progressPercent=Math.round(((goto+1)/totalSteps)*100);var progStyle=document.querySelector('#'+formID+'__form_progress').dataset.style||'style1';if(progStyle==='style2'){progressPercent=Math.round(((goto)/(totalSteps-1))*100)} 37if(document.querySelector('#'+formID+'__form_progress .bravepopupform_theProgressbar_steps')){document.querySelector('#'+formID+'__form_progress .bravepopupform_theProgressbar_steps').innerHTML=(goto+1)+'/'+(totalSteps);document.querySelector('#'+formID+'__form_progress .bravepopupform_theProgressbar_progress').innerHTML=progressPercent+'%'} 38document.querySelector('#'+formID+'__form_progress .bravepopupform_theProgressbar__bar').style.width=progressPercent+'%'}} 39function brave_form_goBack(formID,totalSteps){var currentStep=document.querySelector('#brave_form_'+formID+' .brave_form_fields').dataset.step;var formBackButton=document.querySelector('#brave_form_'+formID+' .brave_form_stepBack');var goto=currentStep-1;document.querySelector('#brave_form_'+formID+' .brave_form_fields').dataset.step=goto;brave_popup_formData[formID].currentStep=goto;brave_form_changeHeight(formID,goto);brave_form_progress(formID,goto,totalSteps);if(goto===0){formBackButton.classList.add('brave_form_stepBack--hide')}else{formBackButton.classList.remove('brave_form_stepBack--hide')} 40var allformSteps=document.querySelectorAll('#brave_form_'+formID+' .brave_form_fields_step');for(var i=0;i<allformSteps.length;i++){if(i===goto){allformSteps[i].classList.add('brave_form_fields_step--show')}else{allformSteps[i].classList.remove('brave_form_fields_step--show')}} 41if(goto===(totalSteps-1)){document.querySelector('#brave_form_'+formID+' .brave_form_button').classList.remove('brave_form_button--hide')}else{document.querySelector('#brave_form_'+formID+' .brave_form_button').classList.add('brave_form_button--hide')}} 42function brave_form_gotoStep(formID,totalSteps,goto){var braveForm=d
42ocument.getElementById('brave_form_'+formID);var fieldsData=brave_get_field_vals(braveForm,JSON.parse(brave_popup_formData[formID].fields)) 43var stepFieldIDs=[];var currentStep=document.querySelector('#brave_form_'+formID+' .brave_form_fields_step'+(goto-1));if(currentStep){var allStepFields=currentStep.querySelectorAll('.brave_form_field');for(var i=0;i<allStepFields.length;i++){if(!allStepFields[i].classList.contains('brave_form_field--step')){stepFieldIDs.push(allStepFields[i].getAttribute('id').replace('brave_form_field',''))}}} 44var filteredFieldData={};var emailFields=[];stepFieldIDs.forEach(function(fieldID){if(fieldsData[fieldID]){filteredFieldData[fieldID]=fieldsData[fieldID];if(filteredFieldData[fieldID]&&fieldsData[fieldID].required&&fieldsData[fieldID].validation==='email'&&(!bravepop_emailSuggestions[fieldID])){emailFields.push({ID:fieldID,value:fieldsData[fieldID].value})}}}) 45var formErrors=[];Object.keys(filteredFieldData).forEach(function(fieldID){var fieldError=brave_validate_fields(fieldID,filteredFieldData[fieldID]);if(fieldError){formErrors.push(fieldError)} 46document.querySelector('#brave_form_field'+fieldID).classList.remove('brave_form_field--hasError','brave_form_field--hasSuggestion','brave_form_field--hasError-firstname','brave_form_field--hasError-lastname')});brave_display_form_error(formErrors);if(formErrors.length>0){return} 47var braveFormNextStepActions=function(){brave_form_changeHeight(formID,goto);var allformSteps=document.querySelectorAll('#brave_form_'+formID+' .brave_form_fields_step');for(var i=0;i<allformSteps.length;i++){if(i===goto){document.querySelector('#brave_form_'+formID+' .brave_form_fields').dataset.step=goto;allformSteps[i].classList.add('brave_form_fields_step--show');document.querySelector('#brave_form_'+formID+' .brave_form_fields').style.height=allformSteps[i].offsetHeight+'px';var formBackButton=document.querySelector('#brave_form_'+formID+' .brave_form_stepBack');if(formBackButton){formBackButton.classList.remove('brave_form_stepBack--hide')} 48brave_popup_formData[formID].currentStep=goto}else{allformSteps[i].classList.remove('brave_form_fields_step--show')}} 49brave_form_progress(formID,goto,totalSteps,!1);if(goto===(totalSteps-1)){setTimeout(function(){document.querySelector('#brave_form_'+formID+' .brave_form_button').classList.remove('brave_form_button--hide')},250)}} 50if(bravepop_emailValidation&&emailFields.length>0){var ajaxurl=bravepop_global.ajaxURL;var security=document.getElementById('brave_form_security'+formID).value;var emailData={formData:JSON.stringify(emailFields),freemailAllow:JSON.stringify(brave_popup_formData[formID].freemailAllow||!1),security:security,action:'bravepopup_validate_email'};brave_ajax_send(ajaxurl,emailData,function(status,sentData){var validatedData=JSON.parse(sentData);console.log('Validation response:',validatedData);var emailValidationErrors=[];if(Array.isArray(validatedData)){validatedData.forEach(function(field){if(field.validation&&field.validation.status==='invalid'&&field.validation.errorMsg){emailValidationErrors.push({id:field.ID,message:field.validation.errorMsg,type:"required"})} 51if(field.validation&&field.suggestionMsg){emailValidationErrors.push({id:field.ID,message:field.suggestionMsg,type:"info"})}})} 52if(emailValidationErrors.length>0){brave_display_form_error(emailValidationErrors);if(brave_form){brave_form.classList.remove('brave_form_form--loading')} 53if(brave_login_loader){brave_login_loader.classList.remove('brave_form_loading--show')}}else{braveFormNextStepActions()}})}else{braveFormNextStepActions()}} 54function brave_form_changeHeight(formID,goto){var changesFormHeight=brave_popup_formData[formID].changesFormHeight||!1;if(changesFormHeight){var braveForm=document.getElementById('brave_element-'+formID);var parentPopupStep=braveForm.closest('.brave_popup__step');var initialHeight=brave_popup_formData[formID].heightData[0];var diffHeight=brave_popup_formData[formID].heightData[goto]-initialHeight;var newFormHeight=brave_popup_formData[formID].heightData[goto]||initialHeight;braveForm.style.height=(parseInt(newFormHeight,10))+'px';if(parentPopupStep){var parentPopupHeight=parentPopupStep.dataset.height;parentPopupStep.querySelector('.brave_popup__step__inner').style.height=(parseInt(parentPopupHeight,10)+diffHeight)+'px'}}} 55function brave_get_field_vals(braveForm,fieldOpts,quiz){var fieldsData=fieldOpts;var firstname_val='';for(var i=0;i<braveForm.elements.length;i++){var fieldName=braveForm.elements[i].name.replace('[]','');var fieldOpts=fieldsData[fieldName]||{};var fieldValue=braveForm.elements[i].value;if(fieldOpts&&fieldOpts.type&&(fieldOpts.type==='checkbox'||(fieldOpts.type==='select'&&fieldOpts.multi)||(fieldOpts.type==='image'&&fieldOpts.multi))){var checkedVal=document.querySelectorAll('#brave_form_field'+fieldName+' input
55:checked, #brave_form_field'+fieldName+' option:checked');fieldValue=Array.from(checkedVal).map(function(el){return el.value});if(fieldOpts.required&&(fieldValue.length===0||fieldValue.includes('none'))){fieldValue=''}} 56if(fieldOpts&&fieldOpts.type&&(fieldOpts.type==='rating'||fieldOpts.type==='radio'||fieldOpts.type==='buttons')){var checkedVal=document.querySelectorAll('#brave_form_field'+fieldName+' input:checked, #brave_form_field'+fieldName+' option:checked');var selectedfieldValue=Array.from(checkedVal).map(function(el){return el.value});fieldValue=Array.isArray(selectedfieldValue)&&selectedfieldValue[0]?selectedfieldValue[0]:''} 57if(fieldOpts&&fieldOpts.type&&fieldOpts.type==='input'&&fieldOpts.validation==='name'){if(braveForm.elements[i].classList.contains('brave_form_field_input-firstname')){firstname_val=fieldValue} 58if(braveForm.elements[i].classList.contains('brave_form_field_input-lastname')){fieldsData[fieldName].value=[firstname_val,fieldValue]}}else if(fieldsData[fieldName]){fieldsData[fieldName].value=fieldValue} 59if(fieldsData[fieldName]&&fieldsData[fieldName].required&&document.getElementById('brave_form_field'+fieldName).classList.contains('brave_form_field--hasCondition')){fieldsData[fieldName].required=!1} 60if(fieldOpts&&fieldOpts.type&&fieldOpts.type==='date'&&fieldOpts.validation==='multi'){var dateVal=document.getElementById('brave_form_field'+fieldName+'-date')?document.getElementById('brave_form_field'+fieldName+'-date').value:'';var monthVal=document.getElementById('brave_form_field'+fieldName+'-month')?document.getElementById('brave_form_field'+fieldName+'-month').value:'';var yearVal=document.getElementById('brave_form_field'+fieldName+'-year')?document.getElementById('brave_form_field'+fieldName+'-year').value:new Date().getFullYear();if(dateVal||monthVal){fieldsData[fieldName].value=dateVal+'/'+monthVal+'/'+yearVal}} 61if(quiz&&fieldOpts.options){var selectedOpt=!1;fieldOpts.options.forEach(function(opt){if((fieldOpts.type==='checkbox'||(fieldOpts.type==='select'&&fieldOpts.multi)||(fieldOpts.type==='image'&&fieldOpts.multi))&&fieldValue.includes(opt.value)){selectedOpt=opt} 62if((fieldOpts.type==='radio'||fieldOpts.type==='buttons')&&opt.value===fieldValue){selectedOpt=opt}});if(selectedOpt){fieldsData[fieldName].score=selectedOpt.score?selectedOpt.score:0;fieldsData[fieldName].correct=selectedOpt.correct?selectedOpt.correct:!1}}} 63return fieldsData} 64function brave_submit_form(event,settings,supressErrors=!1){if(event){event.preventDefault()} 65var braveForm=document.getElementById('brave_form_'+settings.formID);var originalFields=JSON.parse(settings.fields);var fieldsData=brave_get_field_vals(braveForm,originalFields,settings.quiz) 66var ajaxurl=bravepop_global.ajaxURL;var security=document.getElementById('brave_form_security'+settings.formID).value;var formErrors=[];Object.keys(fieldsData).forEach(function(fieldID){var fieldError=brave_validate_fields(fieldID,fieldsData[fieldID]);if(fieldError){formErrors.push(fieldError)} 67document.querySelector('#brave_form_field'+fieldID).classList.remove('brave_form_field--hasError','brave_form_field--hasSuggestion','brave_form_field--hasError-firstname','brave_form_field--hasError-lastname')});brave_display_form_error(formErrors);var finalFieldsData={};var quizData={};var emailFields=[];var quizScore=0;var availableScore=0;var quizCorrect=0;Object.keys(fieldsData).forEach(function(fieldID){if(fieldsData[fieldID]){finalFieldsData[fieldID]=fieldsData[fieldID].value} 68if(fieldsData[fieldID]&&fieldsData[fieldID].validation==='name'&&Array.isArray(fieldsData[fieldID].value)){finalFieldsData[fieldID]=fieldsData[fieldID].value.join(' ').trim()} 69if(fieldsData[fieldID]&&fieldsData[fieldID].required&&fieldsData[fieldID].validation==='email'&&(!bravepop_emailSuggestions[fieldID])){emailFields.push({ID:fieldID,value:fieldsData[fieldID].value})} 70if(settings.quiz&&fieldsData[fieldID]&&fieldsData[fieldID].score){quizScore=quizScore+fieldsData[fieldID].score} 71if(settings.quiz&&fieldsData[fieldID]&&fieldsData[fieldID].correct){quizCorrect=quizCorrect+1} 72if(settings.quiz&&fieldsData[fieldID]&&fieldsData[fieldID].topScore){availableScore=availableScore+fieldsData[fieldID].topScore}});if(settings.quiz){brave_popup_formData[settings.formID].totalScore=quizScore;brave_popup_formData[settings.formID].totalCorrect=quizCorrect;brave_popup_formData[settings.formID].availableScore=availableScore;quizData={availableScore:availableScore,userScore:quizScore,userCorrect:quizCorrect,totalQuestions:settings.totalQuestions,scoring:settings.quizScoring}} 73console.log('finalFieldsData: ',quizScore,quizCorrect,fieldsData);console.log(formErrors);if(supressErrors){formErrors=[]} 74if(formErrors.length===0){if(!security||!ajaxurl){return console.log('Security Failed or Ajax URL Missing!!!!',security,ajaxurl)}
74 75var finalData={formData:JSON.stringify(finalFieldsData),popupID:settings.popupID,formID:settings.formID,stepID:settings.stepID,quizData:JSON.stringify(quizData),cookieConditions:"",device:settings.device,userDevice:brave_currentDevice,pageURL:window.location,security:security,action:'bravepop_form_submission'};var brave_form=document.getElementById('brave_form_'+settings.formID);var brave_login_loader=document.getElementById('brave_form_loading_'+settings.formID);if(brave_login_loader){brave_login_loader.classList.add('brave_form_loading--show')} 76if(brave_form){brave_form.classList.add('brave_form_form--loading')} 77var cookiesToCheck=brave_form.dataset.cookies?brave_form.dataset.cookies.split(','):[];if(cookiesToCheck.length>0){var cookiesData={};cookiesToCheck.forEach(function(cookieName){cookiesData[cookieName]=localStorage.getItem(cookieName)?!0:!1}) 78finalData.cookieConditions=JSON.stringify(cookiesData)} 79if(window.location.href.includes('brave_popup')&&window.location.href.includes('brave_preview')&&location.search.split('brave_preview=')[1]){finalData.brave_previewID=location.search.split('brave_preview=')[1]} 80var braveSubmitForm=function(){return brave_ajax_send(ajaxurl,finalData,function(status,sentData){if(brave_login_loader){brave_login_loader.classList.remove('brave_form_loading--show')} 81if(brave_form){brave_form.classList.remove('brave_form_form--loading')} 82if(document.querySelector('#bravepopupform_socialOptin-'+settings.formID)){document.querySelector('#bravepopupform_socialOptin-'+settings.formID).classList.remove('bravepopupform_socialOptin--loading');document.querySelector('#bravepopupform_socialOptin-'+settings.formID).classList.add('bravepopupform_socialOptin--hide');document.querySelector('#brave_element-'+settings.formID+' .brave_element__form_inner').classList.remove('brave_element__form_inner--hide')} 83var response=JSON.parse(sentData);console.log(status,response);localStorage.setItem('brave_popup_'+settings.popupID+'_formsubmitted',!0);var braveFormSubmitEvent=new CustomEvent('brave_form_submitted',{detail:{popupId:parseInt(settings.popupID,10),formId:settings.formID,formData:JSON.stringify(finalFieldsData)}});document.dispatchEvent(braveFormSubmitEvent);if(document.querySelector('#'+settings.formID+'__form_progress')){document.querySelector('#'+settings.formID+'__form_progress').style.display='none'} 84if(settings.track){var formTrackingSettings=JSON.parse(settings.track);if(formTrackingSettings&&formTrackingSettings.enable&&formTrackingSettings.eventCategory&&formTrackingSettings.eventAction){brave_send_ga_event(formTrackingSettings.eventCategory,formTrackingSettings.eventAction,formTrackingSettings.eventLabel||'')} 85if(formTrackingSettings&&formTrackingSettings.enable&&formTrackingSettings.fbq_event_type){brave_send_fbq_event(formTrackingSettings.fbq_event_type,formTrackingSettings.fbq_content_name,formTrackingSettings.fbq_content_category,formTrackingSettings.fbq_value,formTrackingSettings.fbq_currency)}} 86if(brave_popup_formData[settings.formID]&&brave_popup_formData[settings.formID].goal){brave_complete_goal(settings.popupID,'form')} 87Object.keys(fieldsData).forEach(function(fieldID){var fieldVal=Array.isArray(fieldsData[fieldID].value)?fieldsData[fieldID].value.join(','):fieldsData[fieldID].value;if(fieldVal&&fieldsData[fieldID]&&fieldsData[fieldID].save_cookie){localStorage.setItem(fieldsData[fieldID].save_cookie,fieldVal)}});if(response.sent&&response.primaryAction==='content'&&response.contentMessage){if(brave_form){brave_form.classList.add('brave_form_form--hide')} 88document.getElementById('brave_form_custom_content'+settings.formID).innerHTML=response.contentMessage;if(response.autoclose&&response.autoclosetime){setTimeout(function(){var thePopID=parseInt(settings.popupID,10);brave_close_popup(thePopID,brave_popup_data[thePopID].currentStep||0)},parseInt(response.autoclosetime,10)*1000)} 89if(response.download&&response.downloadURL){var downloadURI=response.downloadURL;var filename=response.downloadURL.substring(response.downloadURL.lastIndexOf('/')+1);var link=document.createElement('a');if(typeof link.download==='string'){document.body.appendChild(link);link.download=filename;link.href=downloadURI;link.target='_blank';link.click();document.body.removeChild(link)}else{location.replace(downloadURI)}}} 90brave_popup_formData[settings.formID]&&brave_popup_formData[settings.formID].onSubmit(fieldsData,response);if(response.sent&&response.primaryAction==='redirect'&&response.redirectURL){if(brave_form){brave_form.classList.add('brave_form_form--hide')} 91document.getElementById('brave_form_custom_content'+settings.formID).innerHTML=response.redirectMessage;var redirectTime=response.redirectAfter?(response.redirectAfter*1000):6000;setTimeout(function(){window.location.href=response.redirectURL},redirectTime)} 92if(response.sent&&response.primaryAction==='step'&&response.step&&settings.popupID){var formStep=parseInt(response.step,10);formStep=formStep===0?0:formStep-1;brave_open_popup(settings.popupID,formStep)}
93if(settings.quiz){var quizShortcodes=document.querySelectorAll('.bravepop_quizScore-'+settings.formID);if(quizShortcodes){for(var i=0;i<quizShortcodes.length;i++){var showTotal=quizShortcodes[i].dataset.total&&quizShortcodes[i].dataset.total==='false'?!1:!0;if(settings.quizScoring==='points'){var availableScoreVal=showTotal&&brave_popup_formData[settings.formID].availableScore&&brave_popup_formData[settings.formID].availableScore>=brave_popup_formData[settings.formID].totalScore?'/'+brave_popup_formData[settings.formID].availableScore:'';quizShortcodes[i].innerHTML='<span>'+brave_popup_formData[settings.formID].totalScore+'</span>'+availableScoreVal} 94if(settings.quizScoring==='answer'){var availableQuesVal=showTotal&&brave_popup_formData[settings.formID].totalQuestions?'/'+brave_popup_formData[settings.formID].totalQuestions:'';quizShortcodes[i].innerHTML='<span>'+brave_popup_formData[settings.formID].totalCorrect+'</span>'+availableQuesVal}}}}})} 95var braveSubmitWithEmailValidation=function(){var emailData={formData:JSON.stringify(emailFields),freemailAllow:JSON.stringify(brave_popup_formData[settings.formID].freemailAllow||!1),security:security,action:'bravepopup_validate_email'};brave_ajax_send(ajaxurl,emailData,function(status,sentData){var validatedData=JSON.parse(sentData);console.log('Validation response:',validatedData);var emailValidationErrors=[];if(Array.isArray(validatedData)){validatedData.forEach(function(field){if(field.validation&&field.validation.status==='invalid'&&field.validation.errorMsg){emailValidationErrors.push({id:field.ID,message:field.validation.errorMsg,type:"required"})} 96if(field.validation&&field.validation.suggestionMsg&&field.validation.suggestion){emailValidationErrors.push({id:field.ID,message:field.validation.suggestionMsg,type:"suggestion",suggestion:field.validation.suggestion})}})} 97if(emailValidationErrors.length>0){brave_display_form_error(emailValidationErrors);if(brave_form){brave_form.classList.remove('brave_form_form--loading')} 98if(brave_login_loader){brave_login_loader.classList.remove('brave_form_loading--show')}}else{braveSubmitForm()}})} 99if(settings.recaptcha&&grecaptcha){grecaptcha.execute(settings.recaptcha,{action:'submit'}).then(function(token){if(token){var recaptchaData={token:token,security:security,action:'bravepopup_validate_recaptcha'};brave_ajax_send(ajaxurl,recaptchaData,function(status,valid){console.log('Google Recaptcha Verified!');if(valid==='true'){if(bravepop_emailValidation&&emailFields.length>0){braveSubmitWithEmailValidation()}else{braveSubmitForm()}}else{console.error('Google Recaptcha Failed! Spammer Detected!')}})}else{console.error('Google Recaptcha Failed! Could not Fetch Token!')}})}else{if(bravepop_emailValidation&&emailFields.length>0){braveSubmitWithEmailValidation()}else{braveSubmitForm()}}}} 100function brave_apply_email_suggestion(fieldID,suggestion){document.querySelector('#brave_form_field'+fieldID+' input').value=suggestion;brave_dismiss_email_suggestion(fieldID)} 101function brave_dismiss_email_suggestion(fieldID){document.querySelector('#brave_form_field'+fieldID).classList.remove('brave_form_field--hasError','brave_form_field--hasSuggestion')} 102function brave_display_form_error(formErrors){if(formErrors.length>0){formErrors.forEach(function(error){if(error.fieldType&&error.fieldType==='name'){if(error.firstname){document.querySelector('#brave_form_field'+error.id).classList.add('brave_form_field--hasError-firstname');document.querySelector('#brave_form_field'+error.id+' .brave_form_field_error--firstname').innerHTML=error.message} 103if(error.lastname){document.querySelector('#brave_form_field'+error.id).classList.add('brave_form_field--hasError-lastname');document.querySelector('#brave_form_field'+error.id+' .brave_form_field_error--lastname').innerHTML=error.message}}else{document.querySelector('#brave_form_field'+error.id).classList.add('brave_form_field--hasError');document.querySelector('#brave_form_field'+error.id+' .brave_form_field_error').innerHTML=error.message;if(error.type==='suggestion'&&error.suggestion){document.querySelector('#brave_form_field'+error.id).classList.add('brave_form_field--hasSuggestion');var suggestionApplyBtn='<span onclick="brave_apply_email_suggestion(\''+error.id+'\', \''+error.suggestion+'\')">'+bravepop_global.yes+'</span>';var suggestionDismissBtn='<span onclick="brave_dismiss_email_suggestion(\''+error.id+'\', \''+error.suggestion+'\')">'+bravepop_global.no+'</span>';var suggestionActions='<div id="brave_form_field_suggestion_actions-'+error.id+'" class="brave_form_field_suggestion_actions">'+suggestionApplyBtn+suggestionDismissBtn+'</div>' 104document.querySelector('#brave_form_field'+error.id+' .brave_form_field_error').setAttribute('id','brave_form_field_error--suggestion'+error.id) 105document.querySelector('#brave_form_field'+error.id+' .brave_form_field_error').classList.add('brave_form_field_error--suggestion');document.querySelector('#brave_form_field'+error.id+' .brave_form_field_error').innerHTML=(error.message)+suggestionActions}}})}} 106function brave_validate_fields(fieldID,field){if(!field){return} 107if(field.type==='input'&&field.validation==='name'&&field.required){if(!field.value[0]||!field.value[1]){return{id:fieldID,type:'required',fieldType:'name',message:bravepop_global.field_required,firstname:!field.value[0]?!0:!1,lastname:!field.value[1]?!0:!1}}} 108if(!field.value&&field.required){return{id:fieldID,type:'required',message:bravepop_global.field_required}} 109if(field.required&&(field.type==='input'||field.type==='textarea'||field.type==='date')){if(field.validation!=='name'&&!field.value.trim()){return{id:fieldID,type:'required',message:bravepop_global.field_required}}} 110if(field.value&&field.required&&field.type==='select'&&field.value==='none'){return{id:fieldID,type:'required',message:bravepop_global.field_required}} 111if(field.value&&((field.type==='input'&&field.validation==='text')||field.type==='textarea'||field.type==='date')){if(brave_hasHTML(field.value)){return{id:fieldID,type:'ho_html',message:bravepop_global.no_html_allowed}}} 112if(field.value&&field.type==='input'&&field.validation==='number'){if(brave_isNumber(field.value)===!1){return{id:fieldID,type:'invalid',message:bravepop_global.invalid_number}}} 113if(field.value&&field.type==='input'&&field.validation==='url'){if(brave_isURL(field.value)===!1){return{id:fieldID,type:'invalid',message:bravepop_global.invalid_url}}} 114if(field.value&&field.type==='date'){if(brave_isDate(field.value)===!1){return{id:fieldID,type:'invalid',message:bravepop_global.invalid_date}}} 115if(field.value&&field.type==='input'&&field.validation==='email'){if(brave_isEmail(field.value)===!1){return{id:fieldID,type:'invalid',message:bravepop_global.invalid_email}}}} 116function brave_hasHTML(value){var doc=new DOMParser().parseFromString(value,"text/html");return Array.from(doc.body.childNodes).some(function(node){return node.nodeType===1})} 117function brave_isNumber(value){var numberFormat=RegExp(/^[a-zA-Z]+$/);return numberFormat.test(value)?!1:!0} 118function brave_isEmail(value){var mailformat=RegExp(/^\w+([\.+-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,8})+$/);return mailformat.test(value)?!0:!1} 119function brave_isURL(value){var urlFormat=RegExp(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g);return urlFormat.test(value)?!0:!1} 120function brave_isDate(value){var dateFormat=RegExp(/\d{1,4}[-/]\d{1,2}[-/]\d{1,4}/);var dateFormatTwo=RegExp(/\d{1,4}[-/]\d{1,2}/);var matchedDate=dateFormat.test(value);if(!matchedDate){matchedDate=dateFormatTwo.test(value)} 121return matchedDate?!0:!1} 122function brave_ajax_send(ajaxurl,ajaxData,callbackFunction){var array=[];
122Object.keys(ajaxData).forEach(function(element){array.push(encodeURIComponent(element)+"="+encodeURIComponent(ajaxData[element]))});var dataToSend=array.join("&");var request=new XMLHttpRequest();request.open('POST',ajaxurl,!0);request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');request.onload=function(){if(this.status>=200&&this.status<400){callbackFunction('success',this.response)}else{callbackFunction('error',this.response)}};request.send(dataToSend)} 123function brave_action_step(popupID,currentStep,stepIndex){var selectedPopupStep=document.querySelector('#brave_popup_'+popupID+'__step__'+stepIndex+' .brave_popup__step__'+brave_currentDevice) 124var noMobileContent=selectedPopupStep&&selectedPopupStep.dataset.nomobilecontent==='true'?!0:!1;var currentDevice=noMobileContent?'desktop':brave_currentDevice;var selectedPopupStep=document.querySelector('#brave_popup_'+popupID+'__step__'+currentStep+' .brave_popup__step__'+currentDevice) 125selectedPopupStep.dataset.open='false';brave_open_popup(popupID,stepIndex)} 126function brave_init_popup(popupID,popupData){brave_responsiveness(null,popupID,popupData);if(popupData.forceLoad){return brave_load_popup(popupID,popupData)} 127var triggerType=popupData.settings&&popupData.settings.trigger&&popupData.settings.trigger.triggerType?popupData.settings.trigger.triggerType.split(','):['load'];var utmKeywords=[];var containsKeyword=!1;if(popupData.settings&&popupData.settings.placement&&popupData.settings.placement.utm&&popupData.settings.placement.utmKeywords){utmKeywords=popupData.settings.placement.utmKeywords.split(',')} 128if(utmKeywords.length>0){var currentURL=window.location.href;utmKeywords.forEach(function(key){if(currentURL.includes(key)){containsKeyword=!0}}) 129if(containsKeyword===!1){return console.log('Does Not Match UTM Keywords')}} 130if(popupData.settings&&popupData.settings.placement&&popupData.settings.placement.adblock_check&&window.brave_canRunAds){return console.log('Visitor Doesnt have Ad Blocked Installed! Aborting..')} 131if((popupData.hasDesktopEmbed||(popupData.hasMobileEmbed&&brave_currentDevice==='mobile'))&&!document.getElementById('bravepopup_embedded_'+popupID)){return console.log('Popup shortcode is not found in current page')} 132if(popupData.schedule&&popupData.schedule.active&&popupData.schedule.type){if(popupData.schedule.type==='days'&&popupData.schedule.days.length>0){var currentDay=new Date().getDay();if(!popupData.schedule.days.includes(currentDay)){return console.log('Popup Not Scheduled for Today!')}} 133if(popupData.schedule.type==='dates'&&popupData.schedule.dates.length>0){var thecurrentDate=new Date().getTime();var dateInRange=!1;popupData.schedule.dates.forEach(function(date){var theTimes=[];var timeTypes=['start','end'];timeTypes.forEach(function(val){var theDate=date[val].date.split('/');var theHour=date[val].time&&date[val].time.hour?date[val].time.hour:'00';var theMinutes=date[val].time&&date[val].time.minutes?date[val].time.minutes:'00';theTimes.push(new Date(theDate[2]+'/'+theDate[1]+'/'+theDate[0]+' '+theHour+':'+theMinutes+':00').getTime())}) 134if(theTimes[0]<thecurrentDate&&theTimes[1]>thecurrentDate){dateInRange=!0}});if(!dateInRange){return console.log('Popup Not Scheduled these dates!')}}} 135if(popupData.settings&&popupData.settings.audience&&popupData.settings.audience.devices&&popupData.settings.audience.devices==="desktop"&&brave_currentDevice==='mobile'){return console.log('Device Settings doesnt Match')} 136if(popupData.settings&&popupData.settings.audience&&popupData.settings.audience.devices&&popupData.settings.audience.devices==="mobile"&&brave_currentDevice==='desktop'){return console.log('Device Settings doesnt Match')} 137var popupOpenCount=localStorage.getItem('brave_popup_'+popupID+'_viewed');var popupOpenSessionCount=sessionStorage.getItem('brave_popup_'+popupID+'_viewed');var popupRepeatCountType=popupData.settings&&popupData.settings.frequency&&popupData.settings.frequency.repeatCountType||'lifetime';var popupRepeatDelay=popupData.settings&&popupData.settings.frequency&&popupData.settings.frequency.repeatDelay||!1;var popupRepeatDelayTime=popupData.settings&&popupData.settings.frequency&&popupData.settings.frequency.repeatDelayTime?parseInt(popupData.settings.frequency.repeatDelayTime,10):!1;var repeatCount=popupData.settings&&popupData.settings.frequency&&popupData.settings.frequency.repeatCount?parseInt(popupData.settings.frequency.repeatCount,10):3;if(popupData.settings&&popupData.settings.frequency&&popupData.settings.frequency.repeat&&brave_popup_adminUser===!1){if(popupRepeatCountType==='lifetime'&&parseInt(popupOpenCount,10)>=repeatCount){return console.log('Already Viewed '+repeatCount+' Times. Hiding..')} 138var popupViewStat=localStorage.getItem('brave_popup_'+popupID+'_view_stat');popupViewStat=popupViewStat?JSON.parse(popupViewStat):[];var thecurrentDate=new Date();var thecurrentDay=thecurrentDate.getDate();var thecurrentHour=thecurrentDate.getHours();var thecurrentMonth=thecurrentDate.getMonth();var thecurrentYear=thecurrentDate.getFullYear();var popupViewDayCount=0;var popupViewMonthCount=0;var popupView12hCount=0;var popupView6hCount=0;var popupView1hCount=0;var matchedStats=[];if(popupViewStat){popupViewStat.forEach(function(stat){var statDate=new Date(stat);var statDay=statDate.getDate();var statHour=statDate.getHours();var statMonth=statDate.getMonth();var statYear=statDate.getFullYear();if((statDay===thecurrentDay)&&(statMonth===thecurrentMonth)&&(statYear===thecurrentYear)){popupViewDayCount=popupViewDayCount+1} 139if((statMonth===thecurrentMonth)&&(statYear===thecurrentYear)){popupViewMonthCount=popupViewMonthCount+1} 140if((thecurrentHour-statHour)<12&&(statDay===thecurrentDay)&&(statMonth===thecurrentMonth)&&(statYear===thecurrentYear)){popupView12hCount=popupView12hCount+1} 141if((thecurrentHour-statHour)<6&&(statDay===thecurrentDay)&&(statMonth===thecurrentMonth)&&(statYear===thecurrentYear)){popupView6hCount=popupView6hCount+1} 142if((thecurrentHour-statHour)<1&&(statDay===thecurrentDay)&&(statMonth===thecurrentMonth)&&(statYear===thecurrentYear)){popupView1hCount=popupView1hCount+1} 143if(!matchedStats.includes(stat)){matchedStats.push(stat)}})} 144matchedStats=matchedStats.sort();var lastViewedTime=matchedStats.length>0?matchedStats[matchedStats.length-1]:0;var viewDelayMatched=popupRepeatDelay&&popupRepeatDelayTime?(thecurrentDate.getTime()-lastViewedTime)>popupRepeatDelayTime:!0;var viewCountError='Already Viewed '+repeatCount+' Times in last '+popupRepeatCountType+' Hiding..' 145console.log(lastViewedTime,thecurrentDate.getTime(),popupRepeatDelayTime,(thecurrentDate.getTime()-lastViewedTime)>popupRepeatDelayTime);if(viewDelayMatched){console.log(lastViewedTime,thecurrentDate.getTime(),popupRepeatDelayTime,(thecurrentDate.getTime()-lastViewedTime)>popupRepeatDelayTime);if(popupRepeatCountType==='12h'&&(parseInt(popupView12hCount,10)>=repeatCount)){return console.log(viewCountError)} 146if(popupRepeatCountType==='6h'&&(parseInt(popupView6hCount,10)>=repeatCount)){return console.log(viewCountError)} 147if(popupRepeatCountType==='1h'&&(parseInt(popupView1hCount,10)>=repeatCount)){return console.log(viewCountError)} 148if(popupRepeatCountType==='session'&&(parseInt(popupOpenSessionCount,10)>=repeatCount)){return console.log(viewCountError)} 149if(popupRepeatCountType==='day'&&(parseInt(popupViewDayCount,10)>=repeatCount)){return console.log(viewCountError)} 150if(popupRepeatCountType==='month'&&(parseInt(popupViewMonthCount,10)>=repeatCount)){return console.log(viewCountError)}}else{return console.log('Repeat Delay Doesnt Match! Hiding....')}} 151var popupCloseStat=localStorage.getItem('brave_popup_'+popupID+'_closed')?JSON.parse(localStorage.getItem('brave_popup_'+popupID+'_closed')):null;if(popupData.settings&&popupData.settings.frequency&&popupData.settings.frequency.close&&popupCloseStat&&popupCloseStat.closed){var popupCloseCount=popupData.settings.frequency.closeCount?popupData.settings.frequency.closeCount:2;var popupCloseFor=popupData.settings.frequency.closeFor?parseInt(popupData.settings.frequency.closeFor,10)*86400*1000:86400*1000*30;var userCloseCount=parseInt(popupCloseStat.closed,10);var userCloseDate=parseInt(popupCloseStat.closeTime,10);var currentDate=new Date().getTime();var closeTimeDiff=currentDate-userCloseDate;var closeDelayMatched=popupRepeatDelay&&popupRepeatDelayTime?(currentDate-userCloseDate)>popupRepeatDelayTime:!0;console.log('##### CLOSING STATS',userCloseCount,popupCloseFor,closeTimeDiff,closeTimeDiff>=popupCloseFor,userCloseCount>=popupCloseCount,closeDelayMatched,currentDate-userCloseDate);if((closeTimeDiff<=popupCloseFor&&(userCloseCount>=popupCloseCount))||!closeDelayMatched){return console.log('Close Time Settings Do not Match')}} 152if(popupData.settings&&popupData.settings.frequency&&popupData.settings.frequency.formSubmit&&localStorage.getItem('brave_popup_'+popupID+'_formsubmitted')){return console.log('Form in this Popup already Submitted! Hiding..')} 153if(popupData.settings&&popupData.settings.frequency&&popupData.settings.frequency.goalComplete&&localStorage.getItem('brave_popup_'+popupID+'_goal_complete')){return console.log('Popup Goal Already Completed..')} 154if(popupData.settings&&popupData.settings.frequency&&popupData.settings.frequency.timerEnded&&popupData.timers.length>0&&popupData.timers[0].ended){return console.log('Popup Countdown Timer Ended! Hiding..')} 155if(popupData.settings&&popupData.settings.filters&&popupData.settings.filters.popups_before&&popupData.settings.filters.popups.length>0){var popupFilterFulfilled=!1;popupData.settings.filters.popups.forEach(function(popup){if(!popupFilterFulfilled&&popup.id&&popup.action){var popupActionNegative=popup.action.includes('not_') 156var popActionKey=popupActionNegative?popup.action.replace('not_',''):popup.action 157var popupActionMatched=localStorage.getItem('brave_popup_'+popup.id+'_'+popActionKey);if(!popupActionNegative&&popupActionMatched){popupFilterFulfilled=!0} 158if(popupActionNegative&&!popupActionMatched){popupFilterFulfilled=!0}}}) 159if(!popupFilterFulfilled){return console.log('A selected Popup was not viewed before! Hiding..')}} 160if(popupData.settings&&popupData.settings.filters&&popupData.settings.filters.cookieFilter&&popupData.settings.filters.cookies&&popupData.settings.filters.cookies.length>0){var cookieMatched=!1;
160popupData.settings.filters.cookies.forEach(function(cookie){if(!cookieMatched&&cookie.action==='has'&&cookie.key&&localStorage.getItem(cookie.key)){cookieMatched=!0} 161if(!cookieMatched&&cookie.action==='nothas'&&cookie.key&&!localStorage.getItem(cookie.key)){cookieMatched=!0} 162if(!cookieMatched&&cookie.action==='equal'&&cookie.key&&cookie.value&&localStorage.getItem(cookie.key)===cookie.value){cookieMatched=!0} 163if(!cookieMatched&&cookie.action==='notequal'&&cookie.key&&cookie.value&&localStorage.getItem(cookie.key)!==cookie.value){cookieMatched=!0}}) 164if(cookieMatched===!1){return console.log('Visitor Cookie did not match! Hiding..')}} 165if(popupData.settings&&popupData.settings.filters&&((popupData.settings.filters.pages_count_filter&&popupData.settings.filters.pagecount)||(popupData.settings.filters.pages_before&&popupData.settings.filters.pages))){var viewCountLimit=parseInt(popupData.settings.filters.pagecount,10);var current_page_view_data=localStorage.getItem('brave_page_visited');current_page_view_data=current_page_view_data?JSON.parse(current_page_view_data):[];if(popupData.settings.filters.pages_count_filter&&popupData.settings.filters.pagecount&¤t_page_view_data&&(current_page_view_data.length<viewCountLimit)){return console.log('Visitor did not view enough pages to show the popup! Hiding..')} 166var pageConditionMatch=[];var viewConditionMatched=!0;if(popupData.settings.filters.pages_before&&popupData.settings.filters.pages&&popupData.settings.filters.pages.length>0){var pagesmatched=[];var braveMatchPageViewTime=function(timeLimit,viewTime){if(!timeLimit){return!0} 167if(viewTime>timeLimit){return!0}else{return!1}} 168var braveCheckIfViewedPageMatch=function(pageCond,checkExistence=!0,timeLimit){var pageCondID=pageCond.id;var pageCondType=pageCond.type;var conditionMatched=!1;current_page_view_data.forEach(function(pgView){var timeMatch=braveMatchPageViewTime(timeLimit,pgView.time);var pageMatch=pgView.PID===pageCondID&&pgView.type===pageCondType&&timeMatch;if(pageMatch&&checkExistence){conditionMatched=!0}}) 169return conditionMatched} 170var braveCheckIfNotViewedPageMatch=function(pageCond,checkExistence=!1,timeLimit){var pageCondID=pageCond.id;var pageCondType=pageCond.type;var conditionMatched=!0;current_page_view_data.forEach(function(pgView){var timeMatch=braveMatchPageViewTime(timeLimit,pgView.time);var pageMatch=pgView.PID===pageCondID&&pgView.type===pageCondType&&timeMatch;if(pageMatch&&!checkExistence){conditionMatched=!1}}) 171return conditionMatched} 172popupData.settings.filters.pages.forEach(function(pageCond){var currentTime=new Date().getTime();var timeLimit=currentTime-10800000;if(pageCond.duration==='lifetime'){timeLimit=!1} 173if(pageCond.duration==='1day'){timeLimit=currentTime-86400000}if(pageCond.duration==='7days'){timeLimit=currentTime-604800000}if(pageCond.duration==='30days'){timeLimit=currentTime-2592000000} 174var condMatch=pageCond.action.includes('not_viewed')?braveCheckIfNotViewedPageMatch(pageCond,!1,timeLimit):braveCheckIfViewedPageMatch(pageCond,!0,timeLimit);pagesmatched.push({matched:condMatch,forced:pageCond.condition==='and'?!0:!1}
174)}) 175pagesmatched.forEach(function(matchItm){if(matchItm.forced===!0&&matchItm.matched===!0){pageConditionMatch.push(!0)} 176if(matchItm.forced===!0&&matchItm.matched===!1){pageConditionMatch.push(!1)} 177if(matchItm.forced===!1&&(matchItm.matched===!0||matchItm.matched===!1)){pageConditionMatch.push(!0)}}) 178pageConditionMatch.forEach(function(bool){if(bool===!1){viewConditionMatched=!1}}) 179if(!viewConditionMatched){return console.log('Visitor did not view the selected pages before to show the popup! Hiding..')}}} 180if(triggerType.includes('load')){brave_load_popup(popupID,popupData,'load')} 181if(triggerType.includes('exit')){if(brave_currentDevice==='mobile'){if(!popupData.settings.trigger.exitMobileFallback||(popupData.settings.trigger.exitMobileFallback&&popupData.settings.trigger.exitMobileFallback.type&&popupData.settings.trigger.exitMobileFallback.type==='load')){brave_load_popup(popupID,popupData,'load')} 182if(popupData.settings.trigger.exitMobileFallback&&popupData.settings.trigger.exitMobileFallback.type&&popupData.settings.trigger.exitMobileFallback.type==='time'){var exitMobileDelay=popupData.settings.trigger.exitMobileFallback.time||2000;setTimeout(function(){brave_load_popup(popupID,popupData,'time')},(exitMobileDelay*1000))}}else{document.addEventListener("mouseout",function(evt){if((evt.toElement===null||evt.toElement===undefined)&&(evt.relatedTarget===null)){brave_load_popup(popupID,popupData,'exit')}})}} 183if(triggerType.includes('scroll')||(brave_isMobile&&popupData.settings.trigger.exitMobileFallback&&popupData.settings.trigger.exitMobileFallback.type&&popupData.settings.trigger.exitMobileFallback.type==='scroll')){var currentPopup=document.getElementById('brave_popup_'+popupID+'__step__0');var noMobileContent=currentPopup&¤tPopup.classList.contains('brave_popup__step--mobile-noContent')===!0?!0:!1;var currentDevice=noMobileContent?'desktop':brave_currentDevice;var scrollHide=popupData.settings&&popupData.settings.trigger&&popupData.settings.trigger.scrollHide?!0:!1;var scrollTriggerPopup=function(scrollPercent,percentLimit=20,currentPopStep,currentPopStepVisible,between=!1){var scrollPercentVal=between&&percentLimit.split('-');var startScrollPercent=scrollPercentVal&&scrollPercentVal[0]&&parseInt(scrollPercentVal[0],10);var endScrollPercent=scrollPercentVal&&scrollPercentVal[1]&&parseInt(scrollPercentVal[1],10);if(brave_popup_data[popupID].userClosed){return} 184if((!between&&(scrollPercent>=percentLimit))||((between&&!isNaN(startScrollPercent)&&!isNaN(endScrollPercent))&&((scrollPercent>=startScrollPercent)&&(scrollPercent<=endScrollPercent)))){if(!brave_popup_data[popupID].loaded){brave_load_popup(popupID,popupData,'scroll')}else{if(!currentPopStepVisible){brave_open_animation(popupID,0,currentDevice);currentPopStep.dataset.open=!0}}}else{if((between||scrollHide)&¤tPopStepVisible){brave_close_animation(popupID,0,currentDevice);currentPopStep.dataset.open=!1}}} 185document.addEventListener("scroll",function(evt){var h=document.documentElement,b=document.body,st='scrollTop',sh='scrollHeight';var scrollPercent=(h[st]||b[st])/((h[sh]||b[sh])-h.clientHeight)*100;var currentPopStep=document.querySelector('#brave_popup_'+popupID+'__step__0 .brave_popup__step__'+currentDevice);var currentPopStepVisible=currentPopStep&¤tPopStep.dataset.open==='true'?!0:!1;if(brave_isMobile&&(popupData.settings.trigger.exitMobileFallback&&popupData.settings.trigger.exitMobileFallback.type&&popupData.settings.trigger.exitMobileFallback.type==='scroll')){var exitMobielScroll=popupData.settings.trigger.exitMobileFallback.scroll||15;if(scrollPercent>=exitMobielScroll){brave_load_popup(popupID,popupData,'scroll')}} 186if(popupData.settings&&popupData.settings.trigger.scrolltype&&popupData.settings.trigger.scrolltype==='ten'){scrollTriggerPopup(scrollPercent,10,currentPopStep,currentPopStepVisible)} 187if(popupData.settings&&popupData.settings.trigger.scrolltype&&popupData.settings.trigger.scrolltype==='twenty'){scrollTriggerPopup(scrollPercent,20,currentPopStep,currentPopStepVisible)} 188if(popupData.settings&&popupData.settings.trigger.scrolltype&&popupData.settings.trigger.scrolltype==='half'){scrollTriggerPopup(scrollPercent,50,currentPopStep,currentPopStepVisible)} 189if(popupData.settings&&popupData.settings.trigger.scrolltype&&popupData.settings.trigger.scrolltype==='seventy'){scrollTriggerPopup(scrollPercent,70,currentPopStep,currentPopStepVisible)} 190if(popupData.settings&&popupData.settings.trigger.scrolltype&&popupData.settings.trigger.scrolltype==='end'){scrollTriggerPopup(scrollPercent,95,currentPopStep,currentPopStepVisible)} 191if(popupData.settings&&popupData.settings.trigger&&popupData.settings.trigger.scrolltype==='between'&&popupData.settings.trigger.scrollBetween&&popupData.settings.trigger.scrollBetween.includes('-')){scrollTriggerPopup(scrollPercent,popupData.settings.trigger.scrollBetween,currentPopStep,currentPopStepVisible,!0)} 192if(popupData.settings&&popupData.settings.trigger.scrolltype&&popupData.settings.trigger.scrollto&&popupData.settings.trigger.scrolltype==='custom'){var scrollToIDs=popupData.settings.trigger.scrollto||'';var scrolltoElms=scrollToIDs&&document.querySelectorAll(scrollToIDs);if(scrollToIDs&&scrolltoElms){for(var i=0;i<scrolltoElms.length;i++){var scrolltoElm=scrolltoElms[i];if(scrolltoElm&&brave_is_in_view(scrolltoElm)){brave_load_popup(popupID,popupData,'scroll')}}}}},{passive:!0})} 193if(popupData.settings&&popupData.settings.content&&popupData.settings.content.highlight){document.addEventListener("scroll",function(evt){var contentElm=document.querySelector('.bravepopup_embedded--highlight_'+popupID);var contenthlElm=document.getElementById('bravepopup_embedded__bg_'+popupID);var contentAlreadyHighlighted=!1;if(popupData.settings.content.highlight==='once'){contentAlreadyHighlighted=contentElm.classList.contains('bravepopup_embedded__highlight--done')?!0:!1} 194if(contentElm&&(popupData.settings.content.highlight==='always'||(!contentAlreadyHighlighted&&popupData.settings.content.highlight==='once'))){var embeddedContentRect=contentElm.getBoundingClientRect();
194var embeddedViewRatio=(embeddedContentRect.top/document.documentElement.clientHeight)*100;if((embeddedViewRatio<50&&embeddedViewRatio>-20)&&!contenthlElm.classList.contains('bravepopup_embedded__bg--active')){contenthlElm.classList.add('bravepopup_embedded__bg--active');contentElm.classList.add('bravepopup_embedded__highlight--active')} 195if((embeddedViewRatio<-20||embeddedViewRatio>50)&&contenthlElm.classList.contains('bravepopup_embedded__bg--active')){contenthlElm.classList.remove('bravepopup_embedded__bg--active');contentElm.classList.remove('bravepopup_embedded__highlight--active');if(popupData.settings.content.highlight){contentElm.classList.add('bravepopup_embedded__highlight--done')}}}},{passive:!0})} 196if(triggerType.includes('click')&&popupData.settings&&popupData.settings.trigger.clickElements){var clickElms=document.querySelectorAll(popupData.settings.trigger.clickElements);if(clickElms){for(var i=0;i<clickElms.length;i++){var clickElm=clickElms[i];clickElm.addEventListener("click",function(evt){evt.preventDefault();document.getElementById('brave_popup_'+popupID).style.zIndex=9999999999;brave_load_popup(popupID,popupData,'click')})}}} 197if(triggerType.includes('time')&&popupData.settings&&popupData.settings.trigger.time&&(popupData.settings.trigger.time.hours||popupData.settings.trigger.time.minutes||popupData.settings.trigger.time.seconds)){var triggerHours=popupData.settings.trigger.time.hours?parseInt(popupData.settings.trigger.time.hours,10):0;var triggerMinutes=popupData.settings.trigger.time.minutes?parseInt(popupData.settings.trigger.time.minutes,10):0;var triggerSeconds=popupData.settings.trigger.time.seconds?parseInt(popupData.settings.trigger.time.seconds,10):0;var totalTriggerDelay=(triggerHours*3600)+(triggerMinutes*60)+(triggerSeconds);totalTriggerDelay=totalTriggerDelay*1000;setTimeout(function(){brave_load_popup(popupID,popupData,'time')},totalTriggerDelay)}} 198function brave_load_popup(popupID,popupData,triggerType='load'){if(brave_popup_data[popupID]&&brave_popup_data[popupID].ajaxLoad&&!brave_popup_data[popupID].ajaxLoaded){var loadData={popupID:popupID,type:brave_popup_data[popupID].type,security:bravepop_global.security,current_url:location.href,action:'bravepop_ajax_load_popup_content'};brave_ajax_send(bravepop_global.ajaxURL,loadData,function(status,sentData){brave_popup_data[popupID].ajaxLoaded=!0;var selectedPopup=document.getElementById('brave_popup_'+popupID);if(selectedPopup){selectedPopup.innerHTML=sentData;brave_process_open_popup(popupID,popupData,triggerType)}})}else{brave_process_open_popup(popupID,popupData,triggerType)}} 199function brave_process_open_popup(popupID,popupData,triggerType='load'){var selectedPopup=document.getElementById('brave_popup_'+popupID);var popupLoadStatus=selectedPopup?selectedPopup.dataset.loaded:'false';if(popupLoadStatus==='false'){if(popupData.hasYoutube){var YTtag=document.createElement('script');YTtag.src="https://www.youtube.com/iframe_api";var PageFirstScript_YT=document.getElementsByTagName('script')[0];PageFirstScript_YT.parentNode.insertBefore(YTtag,PageFirstScript_YT)} 200if(popupData.hasVimeo){var VimTag=document.createElement('script');VimTag.src="https://player.vimeo.com/api/player.js";var PageFirstScript_Vim=document.getElementsByTagName('script')[0];PageFirstScript_Vim.parentNode.insertBefore(VimTag,PageFirstScript_Vim)} 201var dateFields=document.querySelectorAll('.brave_form_field--date');if(window.brave_initPikaday&&dateFields&&dateFields.length>0){for(var i=0,len=dateFields.length;i<len;i++){var dateField=dateFields[i];var startDate=dateField.dataset.startdate?dateField.dataset.startdate:'';var endDate=dateField.dataset.enddate?dateField.dataset.enddate:'';var dateInput=dateField.querySelector('input');brave_initPikaday(dateInput,startDate,endDate)}} 202selectedPopup.dataset.loaded=!0} 203let step=popupData.forceLoad&&popupData.forceStep?parseInt(popupData.forceStep,10)-1:0;if(brave_popup_data[popupID].settings&&brave_popup_data[popupID].settings.frequency&&brave_popup_data[popupID].settings.frequency.rememberLastStep){let foundLastStep=localStorage.getItem('brave_popup_'+popupID+'_last_viewed_step');if(foundLastStep!==undefined&&foundLastStep!==null){step=foundLastStep}} 204if(triggerType==='exit'||triggerType==='scroll'||triggerType==='time'){var triggerFulFilled=document.getElementById('brave_popup_'+popupID).dataset.triggerfulfilled;if(!triggerFulFilled){document.getElementById('brave_popup_'+popupID).dataset.triggerfulfilled=!0;brave_open_popup(popupID,step)}}else{brave_open_popup(popupID,step)} 205if(brave_popup_data[popupID]&&!brave_popup_data[popupID].loaded){brave_popup_data[popupID].loaded=!0}} 206function brave_open_popup(popupID,step=0){var popupData=brave_popup_data[popupID];var selectedPopupStep=document.querySelector('#brave_popup_'+popupID+'__step__'+step+' .brave_popup__step__'+brave_currentDevice) 207var noMobileContent=selectedPopupStep&&selectedPopupStep.dataset.nomobilecontent==='true'?!0:!1;var currentDevice=noMobileContent?'desktop':brave_currentDevice;var selectedPopupStep=document.querySelector('#brave_popup_'+popupID+'__step__'+step+' .brave_popup__step__'+currentDevice);var popupStepOpen=selectedPopupStep?selectedPopupStep.dataset.open:'false';var hasLockScroll=selectedPopupStep.dataset.scrollock?!0:!1;var stickyBar=selectedPopupStep&&selectedPopupStep.dataset.layout==='float'&&selectedPopupStep.dataset.position==='top_center'?!0:!1;if(popupStepOpen!=='false'){return} 208if(!popupData){return} 209console.log('Opening ',popupID,step,popupStepOpen,stickyBar,noMobileContent,currentDevice);brave_popup_data[popupID].currentStep=step;if(window.location.href.includes('brave_popup')===!1&&window.location.href.includes('braveshot')===!1&&!brave_popup_data[popupID].viewStatSent){var viewDate=new Date();var viewYear=viewDate.getFullYear();var viewMonth=brave_number_padding(viewDate.getMonth()+1);var viewDate=brave_number_padding(viewDate.getDate());var goalIsFirstView=!1;if(brave_popup_data[popupID]&&brave_popup_data[popupID].settings&&brave_popup_data[popupID].settings.goalAction&&brave_popup_data[popupID].settings.goalAction.type==='step'&&brave_popup_data[popupID].settings.goalAction.step===0){goalIsFirstView=!0} 210var viewData={popupID:popupID,date:viewYear+'-'+viewMonth+'-'+viewDate,goalIsFirstView:goalIsFirstView,pageURL:window.location,goalUTCTime:new Date().toUTCString(),security:bravepop_global.security,action:'bravepop_ajax_popup_viewed'};brave_ajax_send(bravepop_global.ajaxURL,viewData,function(status,sentData){brave_popup_data[popupID].viewStatSent=!0})} 211var currentPopupStat=localStorage.getItem('brave_popup_'+popupID+'_viewed');localStorage.setItem('brave_popup_'+popupID+'_viewed',currentPopupStat?parseInt(currentPopupStat,10)+1:1);var popupRepeat=popupData.settings&&popupData.settings.frequency&&popupData.settings.frequency.repeat 212var popupRepeatCountType=popupData.settings&&popupData.settings.frequency&&popupData.settings.frequency.repeatCountType||'lifetime';if(popupRepeat&&popupRepeatCountType!=='lifetime'){var theViewStat=localStorage.getItem('brave_popup_'+popupID+'_view_stat');theViewStat=theViewStat?JSON.parse(theViewStat):[];theViewStat.push(new Date().getTime());localStorage.setItem('brave_popup_'+popupID+'_view_stat',JSON.stringify(theViewStat))} 213if(popupRepeat&&popupRepeatCountType==='session'){var currentSessionPopupViews=sessionStorage.getItem('brave_popup_'+popupID+'_viewed')||0;sessionStorage.setItem('brave_popup_'+popupID+'_viewed',parseInt(currentSessionPopupViews,10)+1)} 214if(hasLockScroll){document.body.classList.add('brave_scroll_lock')} 215if(stickyBar){var popupHeight=selectedPopupStep.dataset.height;document.documentElement.style.setProperty('margin-top',popupHeight+'px','important')} 216if(popupData.type!=='content'){var allImages=selectedPopupStep.querySelectorAll('img');for(var i=0;i<allImages.length;i++){if(allImages[i].dataset.lazy){allImages[i].src=allImages[i].dataset.lazy}}} 217if(brave_popup_videos&&brave_popup_videos[popupID]&&Object.keys(brave_popup_videos).length>
2170){Object.keys(brave_popup_videos[popupID]).forEach(function(playerID){if(playerID.includes('youtube')&&brave_popup_videos[popupID][playerID]&&brave_popup_videos[popupID][playerID].stopVideo){brave_popup_videos[popupID][playerID].stopVideo()} 218if(playerID.includes('vimeo')&&brave_popup_videos[popupID][playerID]&&brave_popup_videos[popupID][playerID].pause){brave_popup_videos[popupID][playerID].pause()} 219if(playerID.includes('custom')&&brave_popup_videos[popupID][playerID]&&brave_popup_videos[popupID][playerID].pause){brave_popup_videos[popupID][playerID].pause()}})} 220if(popupData.videoData&&popupData.videoData[step]&&popupData.videoData[step][currentDevice]){var videoObj=popupData.videoData[step][currentDevice];var videoType=videoObj.videoType?videoObj.videoType:'youtube';var videoURL=videoObj.videoUrl?videoObj.videoUrl:'youtube';var videoTracking=videoObj.action&&videoObj.action.track&&videoObj.action.trackData?videoObj.action.trackData:null;var videoSettings={id:videoObj.id,autoplay:videoObj.autoplay||!1,controls:videoObj.controls||!1,mute:videoObj.mute||!1,tracking:videoTracking} 221brave_load_video(videoType,videoURL,videoSettings,popupID)} 222var elmsWithCookie=selectedPopupStep&&selectedPopupStep.querySelectorAll('.brave_element--text_hasCookie .brave_element__text_inner');if(elmsWithCookie&&elmsWithCookie.length>0){brave_replace_dynamic_text_cookie(elmsWithCookie)} 223var hasAnimation=popupData.hasAnimation?popupData.hasAnimation:!1;var advancedAnimation=popupData.advancedAnimation?popupData.advancedAnimation:!1;var hasContAnim=popupData.hasContAnim?popupData.hasContAnim:!1;var animationData=popupData.animationData?popupData.animationData:{};var selectedStep=document.getElementById('brave_popup_'+popupID+'__step__'+step);if(!selectedStep){return} 224var focusableElm=selectedStep.querySelector('.brave_popup--popup .brave_popupMargin__wrap');var closableFocus=selectedStep.querySelector('.brave_popup--popup .brave_popup__close');if(closableFocus){closableFocus.tabIndex=0} 225if(focusableElm){focusableElm.tabIndex=0;setTimeout(()=>{focusableElm.focus()},200)} 226if(selectedStep){var allSteps=document.querySelectorAll('#brave_popup_'+popupID+' .brave_popup__step_wrap');if(allSteps){for(var i=0;i<allSteps.length;i++){allSteps[i].classList.remove('brave_popup__step_wrap--show')}} 227var braveOpenEvent=new CustomEvent('brave_popup_open',{detail:{popupId:parseInt(popupID,10),step:step}});document.dispatchEvent(braveOpenEvent);if(!advancedAnimation){brave_open_animation(popupID,step,currentDevice)} 228if(advancedAnimation&&hasAnimation&&animationData){selectedStep.classList.add('brave_popup__step_wrap--show');brave_animate_popup(animationData,popupID,step,'load')} 229if(hasContAnim&&animationData&&animationData[step][currentDevice]&&animationData[step][currentDevice].elements){var initialDelay=(animationData[step][currentDevice].totalDuration||0)+1200;animationData[step][currentDevice].elements.forEach(function(element){if(element&&element.animation&&element.animation.continious){var theElement=element.id==='popup'?document.querySelector('#brave_popup_'+popupID+'__step__'+step+' .brave_popup__step__inner .brave_popupSections__wrap'):document.getElementById('brave_element-'+element.id);
229var elementID=element.id==='popup'?popupID:element.id;var contAnimType=element.animation.continious.preset||'none';var contAnimDuration=element.animation.continious.duration||500;var contAnimDelay=element.animation.continious.delay||0;if(theElement){setTimeout(function(){theElement.classList.add('brave_element-'+elementID+'_contAnim');if(contAnimDelay>0){setInterval(function(){theElement.classList.add('brave_element-'+elementID+'_contAnim');setTimeout(function(){theElement.classList.remove('brave_element-'+elementID+'_contAnim')},contAnimDuration)},((contAnimDelay>contAnimDuration)?contAnimDelay:contAnimDuration+contAnimDelay))}},initialDelay)}}})}} 230setTimeout(function(){var currentPopupDimension=selectedPopupStep.querySelector('.brave_popup__step__inner').getBoundingClientRect();if((window.innerHeight<currentPopupDimension.height)&&selectedPopupStep.classList.contains('brave_popup__step--boxed')&&selectedPopupStep.classList.contains('position_center')){selectedPopupStep.classList.add('brave_popup_exceeds_windowHeight');selectedPopupStep.classList.add('brave_popup_show_scrollbar')}},100);if(popupData.close[0]&&popupData.close[0][currentDevice]&&popupData.close[0][currentDevice].autoClose&&popupData.close[0][currentDevice].autoCloseDuration){setTimeout(function(){if(!brave_popup_data[popupID].autoClosed){brave_close_popup(popupID,step);if(popupData.close[0][currentDevice].closeStep!=='undefined'&&Number.isInteger(popupData.close[0][currentDevice].closeStep)){brave_open_popup(popupID,popupData.close[0][currentDevice].closeStep)}} 231brave_popup_data[popupID].autoClosed=!0},parseInt(popupData.close[0][currentDevice].autoCloseDuration)*1000)} 232selectedPopupStep.dataset.open=!0;brave_popup_data[popupID].opened=new Date().getTime();if((popupData.settings&&!popupData.settings.goalAction)||(popupData.settings&&popupData.settings.goalAction&&popupData.settings.goalAction.type&&popupData.settings.goalAction.type==='step'&&popupData.settings.goalAction.step!==undefined)){var goalStep=popupData.settings.goalAction&&popupData.settings.goalAction.step?popupData.settings.goalAction.step.toString().split(','):['0'];if(goalStep.includes(step.toString())&&step!==0){brave_complete_goal(popupID,'view')}} 233var allCodeElmGoals=document.querySelectorAll('.brave_element__code--goaled form');if(allCodeElmGoals.length>0){for(var i=0;i<allCodeElmGoals.length;++i){allCodeElmGoals[i].addEventListener('submit',function(){brave_complete_goal(popupID,'form')})}} 234if(brave_popup_data[popupID].settings&&brave_popup_data[popupID].settings.frequency&&brave_popup_data[popupID].settings.frequency.rememberLastStep){localStorage.setItem('brave_popup_'+popupID+'_last_viewed_step',step)}} 235function brave_open_animation(popupID,step,currentDevice){var totalDuration=brave_popup_data[popupID].animationData[step][currentDevice].totalDuration;var openAnimData=brave_popup_data[popupID].animationData[step][currentDevice].elements?brave_popup_data[popupID].animationData[step][currentDevice].elements:[];var hasAnimation=brave_popup_data[popupID].hasAnimation;var selectedStep=document.querySelector('#brave_popup_'+popupID+'__step__'+step);if(window.location.href.includes('braveshot')===!0&&window.location.href.includes('brave_id')===!0){return selectedStep.classList.add('brave_popup__step_wrap--show')} 236var brave_animateElement=function(elementID,selectedStep,elementDom,step,animType){selectedStep.classList.add('brave_popup__step_wrap--show');if(animType==='text'){var selected_text_element=document.querySelector('#brave_element-'+elementID+' .brave_element__text_inner');var selected_text_element_HTML=selected_text_element.innerHTML;
236var selected_text_element_content=selected_text_element.textContent;var newHTLArray=selected_text_element_content.toString().split('');var selected_text_element_clone=selected_text_element;selected_text_element_clone.innerHTML='';for(var i=0;i<=(newHTLArray.length-1);i++){(function(ind){setTimeout(function(){selected_text_element_clone.innerHTML=selected_text_element_clone.innerHTML+newHTLArray[ind]},1000+(50*ind))})(i)} 237setTimeout(function(){selected_text_element_clone.innerHTML=selected_text_element_HTML},1000+(50*(newHTLArray.length-1)))}else{if(!elementDom.classList.contains('brave_element-'+elementID+'_'+step+'_openAnim')){elementDom.classList.add('brave_element-'+elementID+'_'+step+'_openAnim')}}} 238if(hasAnimation&&openAnimData.length>0){selectedStep.classList.add('brave_popup__step_wrap--show');openAnimData.forEach(function(element){if(element.animation&&element.animation.load&&element.animation.load.preset){var animType=element.animation.load.preset;var animDuration=element.animation.load.duration;var animDelay=element.animation.load.delay||0;
238var elementID=element.id==='popup'?popupID:element.id;var elementDom=element.id==='popup'?selectedStep.querySelector('.brave_popup__step__'+currentDevice+' .brave_popupSections__wrap'):selectedStep.querySelector('.brave_popup__step__'+currentDevice+' #brave_element-'+element.id);elementDom.style.opacity=0;selectedStep.classList.remove('brave_popup__step_wrap--show');if(animDelay){brave_animateElement(elementID,selectedStep,elementDom,step,animType)}else{brave_animateElement(elementID,selectedStep,elementDom,step,animType)} 239if(element.id==='popup'){animDelay=0} 240setTimeout(function(){elementDom.style.opacity=''},animDelay+animDuration-100);setTimeout(function(){elementDom.classList.remove('brave_element-'+elementID+'_'+step+'_openAnim')},animDelay+animDuration+500)}})}else{selectedStep.classList.add('brave_popup__step_wrap--show')}} 241function brave_close_animation(popupID,step,currentDevice){var selectedStep=document.getElementById('brave_popup_'+popupID+'__step__'+step);var selectedStepDevice=selectedStep.querySelector('.brave_popup__step__'+currentDevice);var exitAnimation=selectedStepDevice.dataset.exitanimtype||'';var exitAnimationDuration=selectedStepDevice.dataset.exitanimlength?parseFloat(selectedStepDevice.dataset.exitanimlength,10):0.5;var hasAnimation=brave_popup_data[popupID].hasAnimation?brave_popup_data[popupID].hasAnimation:!1;var advancedAnimation=brave_popup_data[popupID].advancedAnimation?brave_popup_data[popupID].advancedAnimation:!1;var animationData=brave_popup_data[popupID].animationData?brave_popup_data[popupID].animationData:{};var hasCustomExitAnimation=animationData[step][currentDevice].totalDuration.exit;if(selectedStep){if(exitAnimation){selectedStepDevice.querySelector('.brave_popupSections__wrap').classList.add('brave_element-'+popupID+'_'+step+'_exitAnim');setTimeout(function(){selectedStep.classList.remove('brave_popup__step_wrap--show')},(exitAnimationDuration*1000));setTimeout(function(){selectedStepDevice.querySelector('.brave_popupSections__wrap').classList.remove('brave_element-'+popupID+'_'+step+'_exitAnim')},(exitAnimationDuration*1000)+500);if(selectedStep.querySelector('.brave_popup__step__'+currentDevice+' .brave_popup__step__overlay')){setTimeout(function(){selectedStepDevice.querySelector('.brave_popup__step__overlay').classList.add('brave_popup__step__overlay--hide')},(exitAnimationDuration>0.3?((exitAnimationDuration*1000)-200):200));setTimeout(function(){selectedStepDevice.querySelector('.brave_popup__step__overlay').classList.remove('brave_popup__step__overlay--hide')},(exitAnimationDuration*1000)+500)}}else if(advancedAnimation&&hasCustomExitAnimation){if(advancedAnimation&&hasAnimation&&animationData){brave_animate_popup(animationData,popupID,step,'exit')}}else{selectedStep.classList.add('brave_popup__step_wrap--hide');setTimeout(function(){selectedStep.classList.remove('brave_popup__step_wrap--show')},500);setTimeout(function(){selectedStep.classList.remove('brave_popup__step_wrap--hide')},800)}}} 242function brave_close_popup(popupID,step=0,gotoStep=!1,updateStat=!0){var selectedStep=document.getElementById('brave_popup_'+popupID+'__step__'+step);var selectedPopupStep=selectedStep.querySelector('.brave_popup__step__'+brave_currentDevice);var noMobileContent=selectedPopupStep.dataset.nomobilecontent==='true'?!0:!1;var currentDevice=noMobileContent?'desktop':brave_currentDevice;var hasLockScroll=selectedStep.querySelector('.brave_popup__step__'+currentDevice)&&selectedStep.querySelector('.brave_popup__step__'+currentDevice).dataset.scrollock?!0:!1;var exitAnimation=selectedStep.querySelector('.brave_popup__step__'+currentDevice).dataset.exitanimtype||'';var exitAnimationDuration=selectedStep.dataset.exitanimlength?parseFloat(selectedStep.dataset.exitanimlength,10):0.5;if(hasLockScroll){document.body.classList.remove('brave_scroll_lock')} 243if(selectedStep){if(updateStat){var currentPopupCloseStat=localStorage.getItem('brave_popup_'+popupID+'_closed')?JSON.parse(localStorage.getItem('brave_popup_'+popupID+'_closed')):{};var newCloseStat={closed:currentPopupCloseStat.closed?currentPopupCloseStat.closed+1:1,closeTime:new Date().getTime()} 244localStorage.setItem('brave_popup_'+popupID+'_closed',JSON.stringify(newCloseStat))} 245var selectedPopupStep=selectedStep.querySelector('.brave_popup__step__'+currentDevice);selectedPopupStep.dataset.open='false';if(brave_popup_videos&&Object.keys(brave_popup_videos).length>
2450){Object.keys(brave_popup_videos).forEach(function(popupID){Object.keys(brave_popup_videos[popupID]).forEach(function(playerID){if(brave_popup_videos[popupID][playerID]){if(playerID.includes('youtube')&&brave_popup_videos[popupID][playerID]&&brave_popup_videos[popupID][playerID].stopVideo){brave_popup_videos[popupID][playerID].stopVideo()} 246if(playerID.includes('vimeo')&&brave_popup_videos[popupID][playerID]&&brave_popup_videos[popupID][playerID].pause){brave_popup_videos[popupID][playerID].pause()} 247if(playerID.includes('custom')&&brave_popup_videos[popupID][playerID]&&brave_popup_videos[popupID][playerID].pause){brave_popup_videos[popupID][playerID].pause()}}})})} 248brave_popup_data[popupID].userClosed=!0;var braveCloseEvent=new CustomEvent('brave_popup_close',{detail:{popupId:parseInt(popupID,10),step:step}});document.dispatchEvent(braveCloseEvent);brave_close_animation(popupID,step,currentDevice);setTimeout(function(){if(gotoStep!==!1&&gotoStep>=0){var targetStep=document.getElementById('brave_popup_'+popupID+'__step__'+gotoStep);targetStep.querySelector('.brave_popup__step__desktop').dataset.open=!1;targetStep.querySelector('.brave_popup__step__mobile').dataset.open=!1;brave_open_popup(popupID,gotoStep)} 249var stickyBar=selectedPopupStep.dataset.layout==='float'&&selectedPopupStep.dataset.position==='top_center'?!0:!1;if(stickyBar){var newHeight=document.querySelector('body.admin-bar')?'32px':'0px';document.documentElement.style.setProperty('margin-top',newHeight,'important')} 250document.getElementById('brave_popup_'+popupID).style.zIndex=9999999999},(exitAnimation&&exitAnimationDuration?(exitAnimationDuration*1000):10))}} 251function brave_send_ga_event(eventCategory,eventAction,eventLabel){if("ga" in window&&eventCategory&&eventAction){var tracker=ga.getAll()[0];if(tracker){tracker.send('event',eventCategory,eventAction,eventLabel)}}} 252function brave_send_fbq_event(eventType,fbq_content_name,fbq_content_category,fbq_value,fbq_currency){if(window.fbq&&eventType){var fbqData={};if(fbq_content_name){fbqData.content_name=fbq_content_name} 253if(fbq_content_category){fbqData.content_category=fbq_content_category} 254if(fbq_value){fbqData.value=parseFloat(fbq_value,10)} 255if(fbq_currency){fbqData.currency=fbq_currency} 256if(eventType==='Contact'){fbq('track','Contact')} 257if(eventType==='Lead'){fbq('track','Lead',fbqData);console.log(fbqData)}}} 258function brave_load_video(videoType,videoURL,videoSettings,popupID){var elmID=videoSettings.id.replace(/[^a-zA-Z0-9]+/g,'');if(!brave_popup_videos[popupID]){brave_popup_videos[popupID]={}} 259if(videoType==='custom'){brave_popup_videos[popupID]['video_'+videoType+elmID]=document.getElementById('brave_video_custom_'+videoSettings.id);if(videoSettings.autoplay){brave_play_video(popupID,videoSettings.id,'custom',videoSettings.tracking)}} 260if(videoType==='youtube'){var youtube_regex=new RegExp(/^.*(youtu\.be\/|vi?\/|u\/\w\/|embed\/|\?vi?=|\\&vi?=)([^#\\&\\?]*).*/);var parsed=videoURL.match(youtube_regex);var videoID=parsed&&parsed[2]?parsed[2]:null;if(!brave_popup_videos[popupID]['video_'+videoType+elmID]){setTimeout(function(){brave_popup_videos[popupID]['video_'+videoType+elmID]=new YT.Player('brave_video_iframe'+elmID,{videoId:videoID,playerVars:{'autoplay':!1,'controls':videoSettings.controls?videoSettings.controls:!0,mute:videoSettings.mute?videoSettings.mute:!1},events:{'onReady':function(){return videoSettings.autoplay&&brave_play_video(popupID,videoSettings.id,'youtube',videoSettings.tracking)}}})},1000)}else{if(videoSettings.autoplay){brave_play_video(popupID,videoSettings.id,'youtube',videoSettings.tracking)}}} 261if(videoType==='vimeo'){var vimeo_regex=new RegExp(/https?:\/\/(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/);var parsed=videoURL.match(vimeo_regex);var videoID=parsed&&parsed[3]?parsed[3]:null;if(!brave_popup_videos[popupID]['video_'+videoType+elmID]){setTimeout(function(){brave_popup_videos[popupID]['video_'+videoType+elmID]=new Vimeo.Player('brave_video_iframe'+elmID,{id:videoID,background:videoSettings.controls===!1?!0:!1});setTimeout(function(){if(videoSettings.mute){brave_popup_videos[popupID]['video_'+videoType+elmID].setVolume(0)} 262if(videoSettings.autoplay){brave_play_video(popupID,videoSettings.id,'vimeo',videoSettings.tracking)}},2000)},1000)}else{if(videoSettings.autoplay){brave_play_video(popupID,videoSettings.id,'vimeo',videoSettings.tracking)}}}} 263function brave_play_video(popupID,elmentID,videoType,track=null,inline=!1){console.log('brave_play_video',elmentID,videoType,track);var elmID=elmentID.replace(/[^a-zA-Z0-9]+/g,'');if(!brave_popup_videos[popupID]['video_'+videoType+elmID]){return} 264if(document.getElementById("brave_element-"+elmentID)){document.getElementById("brave_element-"+elmentID).classList.add('brave_element--video-show')} 265if(videoType==='custom'){brave_popup_videos[popupID]['video_'+videoType+elmID].muted=!0;brave_popup_videos[popupID]['video_'+videoType+elmID].play();var videoMuted=brave_popup_videos[popupID]['video_'+videoType+elmID].classList.contains('brave_video_muted');if(!videoMuted){setTimeout(function(){brave_popup_videos[popupID]['video_'+videoType+elmID].muted=!1;brave_popup_videos[popupID]['video_'+videoType+elmID].volume=1;brave_popup_videos[popupID]['video_'+videoType+elmID].play()},100)}} 266if(videoType==='youtube'||videoType==='vimeo'){if(videoType==='youtube'&&brave_popup_videos[popupID]['video_'+videoType+elmID]){brave_popup_videos[popupID]['video_'+videoType+elmID].playVideo()} 267if(videoType==='vimeo'&&brave_popup_videos[popupID]['video_'+videoType+elmID]){brave_popup_videos[popupID]['video_'+videoType+elmID].play().then()}} 268if(inline&&!track){var playButton=document.getElementById('brave_play_video-'+elmentID) 269if(playButton){var eventCategory=playButton.dataset.trackcategory||'';var eventAction=playButton.dataset.trackcategory||'';var eventLabel=playButton.dataset.tracklabel||'';track={eventCategory:eventCategory,eventAction:eventAction,eventLabel:eventLabel}}} 270if(track&&track.eventCategory&&track.eventAction){brave_send_ga_event(track.eventCategory,track.eventAction,track.eventLabel||'')}} 271function brave_complete_goal(popupID,goalType='view',auto=!1){if(window.location.href.includes('brave_popup')===!1&&!brave_popup_data[popupID].goaled){var goalDate=new Date();var goalYear=goalDate.getFullYear();var goalMonth=brave_number_padding(goalDate.getMonth()+1);var goalDay=brave_number_padding(goalDate.getDate());var goalData={popupID:popupID,pageURL:window.location,security:bravepop_global.security,goalType:goalType,views:localStorage.getItem('brave_popup_'+popupID+'_viewed')||1,goalTime:new Date().getTime(),goalDate:goalYear+'-'+goalMonth+'-'+goalDay,goalUTCTime:new Date().toUTCString(),device:brave_currentDevice,auto:auto,action:'bravepop_ajax_popup_complete_goal'};brave_ajax_send(bravepop_global.ajaxURL,goalData,function(status,sentData){brave_popup_data[popupID].goaled=!0;console.log('Goal Complete!!!!!!',sentData)});localStorage.setItem('brave_popup_'+popupID+'_goal_complete',!0);
271var braveGoalCompletEvent=new CustomEvent('brave_goal_complete',{detail:{popupId:parseInt(popupID,10),goalType:goalType}});document.dispatchEvent(braveGoalCompletEvent);if(brave_popup_data[popupID].settings&&brave_popup_data[popupID].settings.notification&&brave_popup_data[popupID].settings.notification.analyticsGoal){setTimeout(function(){brave_send_ga_event('popup','goal',brave_popup_data[popupID].title+' ('+popupID+')'||popupID)},2000)}}} 272function brave_load_fonts(fontArray){var googleFonts=[];var customFonts=[];fontArray.forEach(function(font){const inCustomFontList=bravepop_global&&bravepop_global.customFonts.find((fnt)=>fnt.name===font);if(inCustomFontList){customFonts.push(font)}else{googleFonts.push(font)}}) 273if(googleFonts.length>0){WebFontConfig={google:{families:googleFonts}};(function(){if(!document.getElementById('bravePopu_webfontLoader')){var wf=document.createElement('script');wf.setAttribute("id","bravePopu_webfontLoader");wf.src=('https:'==document.location.protocol?'https':'http')+'://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';wf.type='text/javascript';wf.async='true';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(wf,s)}})()} 274if(bravepop_global.customFonts.length>0&&customFonts.length>0){customFonts.map((font)=>{var foundFont=bravepop_global.customFonts.find((fnt)=>font===fnt.name);if(foundFont&&foundFont.url&&foundFont.url!=='UAF'&&foundFont.name&&foundFont.name.includes('brave_custom-')){var custom_font=new FontFace(foundFont.name,'url('+foundFont.url+')');custom_font.load().then(function(loaded_face){document.fonts.add(loaded_face)}).catch(function(error){console.error(error)})}})}};function brave_is_in_view(elem){var rect=elem.getBoundingClientRect();return(rect.bottom>=0&&rect.right>=0&&rect.top<=(window.innerHeight||document.documentElement.clientHeight)&&rect.left<=(window.innerWidth||document.documentElement.clientWidth))};function brave_save_visitor_pageviews(){if(brave_popup_pageInfo.type==='front'||brave_popup_pageInfo.pageID){var brave_page_visited=localStorage.getItem('brave_page_visited');var currentPageType='page';if(brave_popup_pageInfo.type==='front'){currentPageType='front'} 275var brave_page_visited_new={type:brave_popup_pageInfo.type==='front'?'front':(brave_popup_pageInfo.singleType||brave_popup_pageInfo.type),PID:brave_popup_pageInfo.pageID,time:new Date().getTime()};if(brave_page_visited){var brave_page_visited_newData=JSON.parse(brave_page_visited);brave_page_visited_newData.push(brave_page_visited_new);localStorage.setItem('brave_page_visited',JSON.stringify(brave_page_visited_newData))}else{localStorage.setItem('brave_page_visited',JSON.stringify([brave_page_visited_new]))}}} 276function brave_add_to_cart(elementID){brave_tooltip_open(elementID,'Adding to Cart...','top');setTimeout(function(){brave_tooltip_close()},2000)} 277function brave_close_on_add_to_cart(popupID){setTimeout(function(){popupID&&brave_close_popup(popupID)},2000)} 278function brave_apply_woo_coupon(coupon,popupID,elementID,onCouponApply){if(elementID){document.querySelector('#brave_button_loading_'+elementID).classList.add('brave_button_loading--show')} 279brave_ajax_send(location.href+'/?wc-ajax=apply_coupon',{coupon_code:coupon,security:bravepop_global.couponSecurity},function(){if(onCouponApply==='reload'){location.reload()} 280if(onCouponApply==='close'&&popupID){brave_close_popup(popupID)} 281if(onCouponApply==='cart'&&bravepop_global.cartURL){location.href=bravepop_global.cartURL} 282if(elementID){document.querySelector('#brave_button_loading_'+elementID).classList.remove('brave_button_loading--show')}})} 283function brave_copy_to_clipboard(elementID,tooltipData,position){var copyText=document.getElementById('bravepopup_text_copy-'+elementID);copyText.select();copyText.setSelectionRange(0,99999);document.execCommand("copy");brave_tooltip_open(elementID,'â '+tooltipData,position);setTimeout(function(){brave_tooltip_close()},2000)} 284function brave_tooltip_open(elementID,tooltipData,position){var tooltipDiv=document.getElementById('bravepop_element_tooltip');var tooltipElm=document.getElementById('brave_element-'+elementID);var elmPos=tooltipElm.getBoundingClientRect();if(tooltipDiv){tooltipDiv.innerHTML=tooltipData;tooltipDiv.className='bravepop_element_tooltip-show bravepop_element_tooltip-'+position;var tooltipWidth=tooltipDiv.offsetWidth;tooltipDiv.style.top=(elmPos.top+(elmPos.height/2)-10)+'px';tooltipDiv.style.left=(elmPos.left-(tooltipWidth)-8)+'px';if(position==='right'){tooltipDiv.style.left=(elmPos.left+elmPos.width+8)+'px'} 285if(position==='top'){tooltipDiv.style.top=(elmPos.top-(tooltipDiv.offsetHeight)-4)+'px';tooltipDiv.style.left=(elmPos.left-(tooltipWidth/2)+(elmPos.width/2)-4)+'px'} 286if(position==='bottom'){tooltipDiv.style.top=(elmPos.top+elmPos.height+8)+'px';tooltipDiv.style.left=(elmPos.left-(tooltipWidth/2)+(elmPos.width/2)+8)+'px'}}} 287function brave_tooltip_close(){var tooltipDiv=document.getElementById('bravepop_element_tooltip');if(tooltipDiv){tooltipDiv.innerHTML='';tooltipDiv.className='';tooltipDiv.style.left='';tooltipDiv.style.top=''}} 288function brave_lightbox_open(elementID,contentType,content){var bravelightbox=document.getElementById('bravepop_element_lightbox');var bravelightboxContent=document.getElementById('bravepop_element_lightbox_content');if(contentType==='image'&&bravelightboxContent){bravelightboxContent.innerHTML='<img src="'+content+'" />';bravelightbox.classList.add('bravepop_element_lightbox--open')}} 289function brave_lightbox_close(){var bravelightbox=document.getElementById('bravepop_element_lightbox');var bravelightboxContent=document.getElementById('bravepop_element_lightbox_content');if(bravelightbox&&bravelightboxContent){bravelightbox.classList.remove('bravepop_element_lightbox--open');bravelightboxContent.innerHTML=''}} 290function brave_responsiveness(event,popupID,popupData){if(window.location.href.includes('braveshot')===!0&&window.location.href.includes('brave_id')===!0){return} 291var stepsWithNoMobile=document.querySelectorAll('.brave_popup__step--mobile-noContent');if(brave_isTab||(brave_currentDevice==='mobile'&&document.body.clientWidth<350)){stepsWithNoMobile=document.querySelectorAll('.brave_popup__step_wrap')} 292for(var i=0;i<stepsWithNoMobile.length;i++){var desktopStep=stepsWithNoMobile[i].querySelector('.brave_popup__step__desktop');var mobileStep=stepsWithNoMobile[i].querySelector('.brave_popup__step__mobile');var popupLayout=desktopStep.dataset.layout;var popupPosition=popupLayout==='landing'?'top_center':desktopStep.dataset.position;var popupWidth=parseInt(desktopStep.dataset.width,10);var popupHeight=parseInt(desktopStep.dataset.height,10);var windowWidth=document.body.clientWidth||window.innerWidth;var windowHeight=window.innerHeight;if(brave_currentDevice==='mobile'||brave_isTab){if(((windowWidth<popupWidth)&&popupLayout=='boxed')){var scale=desktopStep?windowWidth/desktopStep.dataset.width:0;var tansformOrigin=popupPosition.includes('top')?'top':'center';desktopStep.querySelector('.brave_popup__step__inner').style.transform='scale('+((scale*95)/100)+')';desktopStep.querySelector('.brave_popup__step__inner').style.transformOrigin=((scale*95)/2)+'px '+tansformOrigin;if(windowWidth<popupWidth&&windowHeight<popupHeight){desktopStep.querySelector('.brave_popup__step__inner').style.transformOrigin='left top';desktopStep.querySelector('.brave_popup__step__inner').style.marginTop=0;desktopStep.querySelector('.brave_popup__step__inner').style.top=0} 293if(popupPosition.includes('center')){var widthRemainder=windowWidth-(popupWidth*(scale*95)/100);var heightRemainder=windowHeight-(popupHeight*(scale*95)/100);desktopStep.querySelector('.brave_popup__step__inner').style.left=widthRemainder>0?(widthRemainder/2)+'px':'0'}} 294if(brave_currentDevice==='mobile'&&windowWidth<321&&((290<popupWidth)||windowHeight<popupHeight)&&(popupLayout=='boxed')&&(popupPosition==='bottom_right')){desktopStep.querySelector('.brave_popup__step__inner').style.transform='scale(0.8)';desktopStep.querySelector('.brave_popup__step__inner').style.transformOrigin='100% bottom'} 295if(brave_currentDevice==='mobile'&&(popupLayout=='float')&&windowWidth<750){desktopStep.querySelector('.brave_popup__step__elements').style.transform='scale('+(((windowWidth/1024)*100)/100)+')';desktopStep.querySelector('.brave_popup__step__elements').style.transformOrigin=(((windowWidth/1024)*100)/2)+'px center'} 296if(popupLayout=='float'&&((brave_isTab&&windowWidth<1024&&windowWidth>760)||(brave_currentDevice==='mobile'&&windowWidth<360&&mobileStep))){if(brave_isTab&&windowWidth<1024&&windowWidth>760){popupWidth=1024}var scale=desktopStep?windowWidth/popupWidth:0;if(!brave_isTab&&windowWidth<360&&mobileStep){popupWidth=360;scale=windowWidth/popupWidth;desktopStep=mobileStep} 297desktopStep.querySelector('.brave_popup__step__elements').style.transform='scale('+((scale*100)/100)+')';desktopStep.querySelector('.brave_popup__step__elements').style.transformOrigin=((scale*100)/2)+'px center'}}} 298var allPopups=document.querySelectorAll('.brave_popup__step');for(var i=0;i<allPopups.length;i++){var aPopupHeight=allPopups[i].dataset.height?parseInt(allPopups[i].dataset.height,10):400;var aPopupPosition=allPopups[i].dataset.position;var aPopupLayout=allPopups[i].dataset.layout;if((window.innerHeight<aPopupHeight)&&aPopupPosition.includes('center')&&aPopupLayout==='boxed'&&!allPopups[i].classList.contains('brave_popup_show_scrollbar')){allPopups[i].classList.add('brave_popup_show_scrollbar','brave_popup_exceeds_windowHeight')}} 299var allEmbeddedPopups=document.querySelectorAll('.bravepopup_embedded');for(var x=0;x<allEmbeddedPopups.length;x++){var popupID=allEmbeddedPopups[x].dataset.popupid;var parentElm=allEmbeddedPopups[x].parentNode;var popup_parent_width=parentElm.clientWidth;var allEmbeddedSteps=allEmbeddedPopups[x].querySelectorAll('.brave_popup__step_wrap');for(var i=0;i<allEmbeddedSteps.length;i++){var currentDevice=allEmbeddedSteps[i].classList.contains('brave_popup__step--mobile-noContent')?'desktop':brave_currentDevice;var selectedStep=allEmbeddedSteps[i].querySelector('.brave_popup__step__'+currentDevice+'.brave_popup__step--embedded');if(selectedStep){var stepWidth=parseInt(selectedStep.dataset.width,10);var stepHeight=parseInt(selectedStep.dataset.height,10);if(popup_parent_width&&(popup_parent_width<stepWidth)){var scale=Math.min(popup_parent_width/stepWidth);selectedStep.querySelector('.brave_popup__step__inner').style.transform='scale('+((scale*98)/100)+')';selectedStep.querySelector('.brave_popup__step__inner').style.transformOrigin='left top';selectedStep.querySelector('.brave_popup__step__inner').parentNode.classList.add('brave_popup__step__inner--scaled');selectedStep.style.height=((stepHeight*(scale*98)/100))+'px'}}}}} 300function brave_click_open_popups(){var braveFoundOpenElems=document.querySelectorAll('a[href*="#brave_open_popup_"]');if(braveFoundOpenElems.length>0){for(var i=0;i<braveFoundOpenElems.length;i++){var rawOpenElmHref=braveFoundOpenElems[i].href;var braveOpenPopupID=rawOpenElmHref&&rawOpenElmHref.split('#brave_open_popup_')[1]?parseInt(rawOpenElmHref.split('#brave_open_popup_')[1],10):!1;if(braveOpenPopupID&&brave_popup_data[braveOpenPopupID]&&document.getElementById('brave_popup_'+braveOpenPopupID)){braveFoundOpenElems[i].addEventListener('click',function(event){event.preventDefault();
300if(document.getElementById('brave_popup_'+braveOpenPopupID))document.getElementById('brave_popup_'+braveOpenPopupID).style.zIndex=9999999999});braveFoundOpenElems[i].setAttribute('onclick','brave_load_popup('+braveOpenPopupID+', brave_popup_data['+parseInt(braveOpenPopupID,10)+'])')}}}} 301function brave_replace_dynamic_text_cookie(elmsWithCookie){if(elmsWithCookie.length>0){for(var i=0;i<elmsWithCookie.length;i++){var finalContent=elmsWithCookie[i].innerHTML;var allShortCodes=finalContent.match(/({{cookie-)+([a-zA-Z0-9_]).+?}}/gi);if(allShortCodes&&allShortCodes.length>0){allShortCodes.forEach(function(shortcode){var theShortcode=shortcode.replace('{{cookie-','').replace('}}','');var cookieVal=localStorage.getItem(theShortcode);finalContent=finalContent.replace(shortcode,cookieVal?cookieVal:'')}) 302elmsWithCookie[i].innerHTML=finalContent}}}} 303function brave_lazyLoad_content_images(emebeddedCampain){if(emebeddedCampain&&!emebeddedCampain.classList.contains('bravepopup_embedded--lazyload_done')&&brave_is_in_view(emebeddedCampain)){var allImages=emebeddedCampain.querySelectorAll('img');for(var i=0;i<allImages.length;i++){if(allImages[i].dataset.lazy){allImages[i].src=allImages[i].dataset.lazy}} 304emebeddedCampain.classList.add('bravepopup_embedded--lazyload_done')}} 305function brave_after_page_load(){var allBraveFonts=[] 306if(!brave_popup_data){return} 307Object.keys(brave_popup_data).forEach(function(popID){brave_popup_data[popID].fonts.forEach(function(fontName){if(!allBraveFonts.includes(fontName)){allBraveFonts.push(fontName)}})});brave_save_visitor_pageviews();brave_load_fonts(allBraveFonts);brave_click_open_popups();var emebddedContent=document.querySelectorAll('.bravepopup_embedded');if(emebddedContent&&emebddedContent.length>0){for(var i=0;i<emebddedContent.length;i++){var emebeddedCampain=emebddedContent[i];if(emebeddedCampain){brave_lazyLoad_content_images(emebeddedCampain);document.addEventListener("scroll",function(){brave_lazyLoad_content_images(emebeddedCampain)},{passive:!0})}}}} 308window.addEventListener('DOMContentLoaded',brave_after_page_load);window.addEventListener('resize',brave_responsiveness)
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.