card.mount('#card-element');
// Handle real-time validation errors from the card Element.
card.addEventListener('change', function(event) {
var displayError = document.getElementById('card-errors');
if (event.error) {
displayError.textContent = event.error.message;
$('#card-errors').show();
} else {
$('#card-errors').hide();
}
});
}
stripeTokenHandler = function(token){
$('.formCheckout').append('
');
try{
latLong = mapCyprus.getCenter().lat+","+mapCyprus.getCenter().lng;
}catch(exc){
latLong = '0';
}
$.ajax({
url: 'https://api.b3eats.com/checkIfDeliver',
type: 'post',
data: $('.formCheckout').serialize()+'&session='+readCookie('sessionId'),
success: function(d){
if (d.deliverInYourArea){
twoStepConfirmation();
$('.formCheckout').append('
');
//$('#loader-content').fadeIn().append('');
//$('.formCheckout')[0].submit();
}else{
openModalWithLink('https://api.b3eats.com/modal/notDelivered?bootstrap=4');
$('.btnConfirmOrder').prop('disabled',false);
$('#loader-content').fadeOut();
}
}
});
}
createSubPagesLinks = function(){
urlParts = window.location.pathname.split('/');
$('[data-alias]').each(function(){
if ($(this).hasClass('rev_slider_wrapper')){
return true;
}
$(this).addClass('ajaxLink');
createURL = '/blog/'+$(this).data('alias')+'/'+urlParts[3];
$(this).attr('href',createURL);
});
}
var isShop;
var lastQuickSearchV ;
lastQuickSearchV = '';
$(function(){
$(document).off('click','.viewMode .viewModeButton').on('click','.viewMode .viewModeButton',function(){
howMany = $(this).data('v');
if ($(this).hasClass('active')){
$(this).removeClass('active');
$('.afterWebsite').html('');
return false;
}
$('.viewMode .viewModeButton').removeClass('active');
$(this).addClass('active');
if (howMany == 2){
$('.afterWebsite').html('');
}
if (howMany == 3){
$('.afterWebsite').html('');
}
if (howMany == 4){
$('.afterWebsite').html('');
}
if (howMany == 5){
$('.afterWebsite').html('');
}
createCookie('howManyViewProducts',howMany,365);
});
$(document).off('click','.removePromoCode').on('click','.removePromoCode',function(){
$('html').addClass('loading');
removeCouponCode = $.ajax({
url: window.location.origin+ '/wolfValidateCoupon?session='+readCookie('sessionId'),
data: ({'coupon':'','session':readCookie('sessionId')}),
cache: false,
type: 'post',
success: function(d){
if (window.location.pathname.includes('/order')){
refreshCart();
$('html').removeClass('loading');
}else{
try{
refreshCheckout();
}catch(exc){
}
}
}
});
});
$(document).off('focus','.searchTerm').on('focus','.searchTerm',function(e){
try{
if (typeof e.type == 'undefined'){
return false;
}
}catch(exc){
}
v = $(this).val();
if (v != ''){
if ($('.searchResults').length == 0){
lastQuickSearchV = '';
$('.searchTerm').trigger('keyup');
}else{
$('.searchResults').show();
$('html').addClass('searching');
}
}
});
$(document).off('keyup','.searchTerm').on('keyup','.searchTerm',function(e){
closestForm = $(this).closest('form');
beforeForm = closestForm.before();
//console.log(beforeForm);
//console.log(e.keyCode);
if (e.keyCode == 27 || e.keyCode == 13){
return false;
}
v = $.trim($(this).val());
if (v == lastQuickSearchV){
return false;
}
if ($('.overlaySearch').length == 0){
$('.mainContent').before('
')
}
hasResult = closestForm.find('.searchResults');
try{
ajaxSearch.abort();
}catch(exc){
}
if (v == ''){
$('.searchResults').hide();
$('html').removeClass('searching');
return false;
}
//console.log(closestForm);
if (hasResult.length == 0 && closestForm.find('.searchResults').length == 0){
closestForm.append('
');
}
$('.searchResults.inline').html('
').show();
$('html').addClass('searching');
try{
clearTimeout(ajaxSearchTimeout);
}catch(exc){
}
ajaxSearchTimeout = setTimeout(function(){
ajaxSearch = $.ajax({
context: this,
timeout: 10000,
type: 'post',
context: ({'val':v}),
data: ({'s':v,'session':readCookie('sessionId')}),
url: 'https://b3.my/api/store/search.php?sessionGet='+readCookie('sessionId'),
success: function(d){
lastQuickSearchV = this.val;
//console.log(d);
$('html').addClass('searching');
$('.searchResults.inline').html(d.html).show();
}
});
},400);
});
$(document).off('click','.editThisAddress').on('click','.editThisAddress',function(e){
id = $(this).data('id');
openModalWithLink('https://wolf.ooo/api/addNewAddressBeta.php?mode=edit&id='+id+'&sessionGet='+readCookie('sessionId'));
try{
dynamicSheet.close();
}catch(exc){
///alert(exc);
}
return false;
});
$(document).off('click','.deleteAddress').on('click','.deleteAddress',function(e){
$this = $(this);
Swal.fire({
text: 'Delete this address?',
icon: 'alert',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Delete'
}).then((result) => {
if (result.value) {
$.ajax({
url: 'https://wolf.ooo/templates/wolf/pages/users/addresses.php',
type: 'post',
data: ({'id':$this.data('id'),'action':'deleteAddress','session':readCookie('sessionId')}),
success: function(d){
try{
$.toast({
heading: 'Address Deleted!',
position: 'bottom-center',
stack: false
});
}catch(exc){
}
getMyAddresses();
try{
if (dynamicSheet.opened){
}else{
openLink(window.location.pathname+window.location.search);
}
}catch(exc){
}
}
});
}
});
return false;
});
$(document).off('click','.getGPSCoordinates').on('click','.getGPSCoordinates',function(){
continueGeolocation = true;
try{
navigator.permissions.query({ name: 'geolocation' }).then(function(status){
if (status.state == 'denied'){
$('.alertDeniedLocation').show();
continueGeolocation = false;
return false;
}
});
}catch(exc){
}
if (continueGeolocation){
$('.loadingLocationInModal').show();
$('.alertDeniedLocation, .getGPSCoordinates').hide();
askForGeolocation(function(){
console.log(position);
createCookie('currentCoordinates',readCookie('currentCoordinatesReal'),365);
createCookie('lastActionLocation','gps',365);
usingCurrentLocation = true;
coordinates = readCookie('currentCoordinates').split(',');
//$('body').append($('#modalConfirmYourAddress'));
//$('#modalConfirmYourAddress').modal('show');
var myLatLng = {lat: parseFloat(coordinates[0]), lng: parseFloat(coordinates[1])};
$('.loadingLocationInModal').hide();
$('.getGPSCoordinates').show();
$('.selectManual').trigger('click');
});
}
});
$(document).off('click','.skipRegister, .continueAsGuest').on('click','.skipRegister, .continueAsGuest',function(e){
e.preventDefault();
$('.modalAjax.loginView').modal('hide');
});
$(document).off('click','.openCountrySelector').on('click','.openCountrySelector',function(){
//console.log($('.countrySelector'));
$('html').addClass('modal-open');
$('.countrySelector').addClass('isOpen');
$('.selectThisCountry img').lazy();
});
$(document).off('click','.closeCountryList').on('click','.closeCountryList',function(){
$('.countrySelector').removeClass('isOpen');
$('html').removeClass('modal-open');
});
$(document).off('click','.selectThisCountry').on('click','.selectThisCountry',function(){
$this = $(this);
$('.countrySelector').removeClass('isOpen');
$('.selectedCountryCode').html('
' + '
'+$this.data('html')+' ');
});
$(document).off('keyup','.searchForCountry').on('keyup','.searchForCountry',function(){
$this = $(this);
value = $.trim($(this).val());
$('.countryList li').hide();
if (value == ''){
$('.countryList li').show();
}
$('.lazyFlag').lazy();
$('.countryList li:wolfcontains("'+value+'")').show();
});
isShop = false;
if ($('.eshopElements').length > 0){
isShop = true;
}
if (isShop){
$('html').addClass('b3shop');
}
createSubPagesLinks();
})