function isOnScreen(elem) {
var $elem = $(elem);
var $window = $(window);
var docViewTop = $window.scrollTop();
var docViewBottom = docViewTop + $window.height();
var elemTop = $elem.offset().top - 200;
var elemBottom = elemTop + $elem.height();
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
function recaptchaCallback() {
$('.g-recaptcha').addClass('confirmed');
}
$(function () {
$('.collection .products img').unveil({
placeholder: window.__URL__ + 'tpl/page/img/loader.gif'
});
$('.collection .products .card').hover(function () {
$(this).find('img.hide').unveil({
placeholder: window.__URL__ + 'tpl/page/img/loader.gif'
});
});
$('#rodoagree .toggle').click(function () {
$(this).hide(100);
$(this).parent().find('label').animate({
height: '160px'
}, 400, function () {
$(this).css({
height: '100%'
});
});
});
$('.gallery').Chocolat({
imageSize: 'contain',
fullScreen: false,
imageSelector: '.fancybox',
loop: true
})
$('.carousel-gallery').Chocolat({
imageSize: 'contain',
fullScreen: false,
imageSelector: '.fancybox',
loop: true
});
$('.realization .image').Chocolat({
imageSize: 'contain',
fullScreen: false,
imageSelector: '.fancybox',
loop: true
});
$('.three-photos').Chocolat({
imageSize: 'contain',
fullScreen: false,
imageSelector: '.fancybox',
loop: true
});
$('#contactFormSend').on('submit', function (evt) {
evt.preventDefault();
var k = ['question', 'name'],
good = true;
$(this).find('[name]').removeClass('error');
$(this).find('p.ajaxInfo').hide();
if (/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test($(this).find('[name="mail"]').val()) == false) {
$(this).find('[name="mail"]').addClass('error');
good = false;
}
for (var i = 0; i < k.length; i++) {
var obj = $(this).find('[name="' + k[i] + '"]');
console.log(obj.val());
if (obj.val().length <= 1) {
good = false;
obj.parents('.form__item').addClass('error');
obj.parents('#rodoagree').addClass('error');
}
}
if ($('.g-recaptcha').hasClass('confirmed')) {
$('.recaptcha_error').hide(300).addClass('hide');
good = true;
} else {
$('.g-recaptcha').addClass('error');
$('.recaptcha_error').show(300).removeClass('hide');
good = false;
}
if (good) {
$.post($(this).attr('action'), $(this).serialize(), (function (response) {
if (response.indexOf('false') === -1) {
$(this).find('input, textarea').val('');
$(this).find('p.ajaxInfo.ok').show();
} else {
$(this).find('p.ajaxInfo.error_send').show();
}
}).bind(this));
} else {
$(this).find('p.ajaxInfo.error').show();
}
});
$('.start-slider').owlCarousel({
responsive: {
0: {
items: 1
},
700: {
items: 1
},
1000: {
items: 3
},
1200: {
items: 3
}
},
autoplayHoverPause: false,
autoplay: false,
autoplayTimeout: 11000,
animateIn: "slideInRight",
animateOut: "slideOutLeft",
loop: false,
center: false,
dots: true,
nav: false,
start: 2,
navText: ['', '']
}).addClass("owl-carousel");
$('.carousel-gallery .carousel').owlCarousel({
responsive: {
0: {
items: 1
},
700: {
items: 2,
margin: 10
},
1000: {
items: 3,
margin: 10
},
1200: {
items: 4,
margin: 10
}
},
dots: false,
loop: false,
thumbs: false,
nav: true,
navText: ['', '']
}).addClass("owl-carousel");
$('.start-offer').owlCarousel({
responsive: {
0: {
items: 1
},
700: {
items: 2,
margin: 10,
nav: false
},
1000: {
items: 3,
margin: 10
},
1200: {
items: 4,
margin: 22
}
},
dots: false,
loop: true,
thumbs: false,
nav: true,
navText: ['', '']
}).addClass("owl-carousel");
$('.start-realization').owlCarousel({
items: 1,
autoplay: true,
autoplayHoverPause: false,
autoplayTimeout: 8000,
dots: false,
loop: true,
thumbs: false,
nav: true,
navText: ['', '']
}).addClass("owl-carousel");
$('.menucall').click(function (e) {
e.preventDefault();
if ($('header nav').hasClass("on")) {
$('body > div').unbind("click");
$('header nav').removeClass("on");
} else {
$('header nav').addClass("on");
}
});
var pageHeight = $('.page-container').height();
$('.background-container').css({
maxHeight: pageHeight
}).addClass('ov-hidden');
$(window).scroll(function (e) {
var _scroll = $(window).scrollTop();
if (_scroll > 100) {
$('header.mobile').addClass("fixed");
} else {
$('header.mobile').removeClass("fixed");
}
if (_scroll > 150) {
$('header.mobile').addClass("moved");
} else {
$('header.mobile').removeClass("moved");
}
});
});