function selectBillingModel(){
(function($){
let radioModel=$('input[name="ad_model"]:checked');
let radioValues=$(".bsaProInputsValues");
let radioValuesCPC=$(".bsaProInputsValuesCPC");
let radioValuesCPM=$(".bsaProInputsValuesCPM");
let radioValuesCPD=$(".bsaProInputsValuesCPD");
$('input[name="ad_limit_cpc"]').prop('checked', false);
$('input[name="ad_limit_cpm"]').prop('checked', false);
$('input[name="ad_limit_cpd"]').prop('checked', false);
$('.bsaInputInnerModel').removeClass('bsaSelected');
radioValues.slideUp();
if(radioModel.val()==='cpc'){
radioValuesCPC.slideDown();
radioModel.parent(1).addClass('bsaSelected');
}else if(radioModel.val()==='cpm'){
radioValuesCPM.slideDown();
radioModel.parent(1).addClass('bsaSelected');
}else if(radioModel.val()==='cpd'){
radioValuesCPD.slideDown();
radioModel.parent(1).addClass('bsaSelected');
}})(jQuery);
}
(function($){
$(document).ready(function(){
if($('#bsaSuccessProRedirect').length){
let getRedirectUrl=$('#bsa_payment_url').val();
setTimeout(function(){
window.location.replace(getRedirectUrl);
}, 2000);
}
if($('#bsaSuccessProAgencyRedirect').length){
let getAgencyRedirectUrl=$('#bsa_payment_agency_url').val();
setTimeout(function(){
window.location.replace(getAgencyRedirectUrl);
}, 2000);
}
let bsaPopupLayer=$('.bsaPopupLayer');
bsaPopupLayer.each(function(){
let child=$(this).first('.bsaProItem');
let childId=$(this).first('.bsaProItem').data('item-id');
if(childId){
child.removeClass('bsaProItem').hide();
$(this).attr('data-item-id', childId).addClass('bsaProItem');
}});
setTimeout(function(){
let bsaProItem=$('.bsaProItem');
bsaProItem.each(function (){
if($(this).data('animation')!=null&&$(this).data('animation')!=='none'){
$(this).addClass('bsaToAnimate');
}else{
$(this).fadeIn(500).removeClass('bsaHidden');
}});
}, 250);
setTimeout(function(){
let bsaProItem=$('.bsaProItem');
bsaProItem.each(function (){
if($(this).hasClass('bsaToAnimate')&&$(this).itemViewableScreen()===true){
$(this).addClass('animated ' + $(this).data('animation')).removeClass('bsaHidden bsaToAnimate');
}});
}, 500);
$.fn.itemViewableScreen=function(){
let win=$(window);
let viewport={
top:win.scrollTop(),
left:win.scrollLeft()
};
viewport.right=viewport.left + win.width();
viewport.bottom=viewport.top + win.height();
let bounds=this.offset();
bounds.right=bounds.left + this.outerWidth();
bounds.bottom=bounds.top + this.outerHeight();
return (!(viewport.right < bounds.left||viewport.left > bounds.right||viewport.bottom < bounds.top||viewport.top > bounds.bottom));
};
let bodyTag=$('body');
if(bodyTag.hasClass('bsa-pro-is-admin')===false&&bodyTag.hasClass('viewable-enabled')===true){
let vis=(function(){
let stateKey, eventKey, keys={
hidden: "visibilitychange",
webkitHidden: "webkitvisibilitychange",
mozHidden: "mozvisibilitychange",
msHidden: "msvisibilitychange"
};
for (stateKey in keys){
if(stateKey in document){
eventKey=keys[stateKey];
break;
}}
return function(c){
if(c) document.addEventListener(eventKey, c);
return !document[stateKey];
}})();
let myTimeout=setInterval(itemViewableChecker, 1000);
document.addEventListener('visibilitychange', function (event){
if(document.hidden){
clearInterval(myTimeout);
}else{
myTimeout=setInterval(itemViewableChecker, 1000);
}});
let ads={};
let ids='';
let counter=0;
let limit=3;
function itemViewableChecker(){
counter++;
let unique={};
let bsaProItem=$('.bsaProItem');
bsaProItem.each(function(){
if($(this).hasClass('inactiveItem')===false){
let $id=$(this).data('item-id');
if($id > 0&&$(this).itemViewableScreen()===true&&vis()===true&&$(this).height() > 0&&$(this).offset().top > 0 ||
$id > 0&&$(this).attr('data-layer-id') > 0&&$(this).hasClass('animated') ||
$id > 0&&$(this).attr('data-background-id') > 0){
ads['time' + $id]=(ads['time' + $id] > 0 ? ads['time' + $id] + 1:1);
ads['timeOut' + $id]=(ads['timeOut' + $id] > 0 ? ads['timeOut' + $id]:1);
if(ads['time' + $id] > ads['timeOut' + $id]&&ads['timeOut' + $id] < 20){
if(!unique[$id]){
ids +=$id + ',';
unique[$id]=1;
ads['timeOut' + $id]=1;
ads['time' + $id]=0;
}}
}}
});
if(ids!==''&&counter > limit){
$.post(bsa_object.ajax_url, {action:'bsa_viewable_callback', a_id: ids, time: counter}, function(result){
if(result > 0){
limit=result;
ids='';
counter=0;
}});
}}
}
$(window).on('scroll', function (){
let scrollTop=$(this).scrollTop();
let windowSize=$(this).height();
let bsaProItem=$('.bsaProItem');
bsaProItem.each(function (){
let prev=$(this).offset();
if($(this).hasClass('bsaToAnimate')&&(scrollTop + windowSize - prev.top) > 0){
$(this).addClass('animated ' + $(this).data('animation')).removeClass('bsaHidden bsaToAnimate');
}});
});
});
})(jQuery);