function isOnScreen(elem) { var $elem = $(elem); var $window = $(window); var docViewTop = $window.scrollTop(); var docViewBottom = docViewTop + $window.height(); var elemTop = $elem.offset().top; var elemBottom = elemTop + $elem.height(); return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop)); } $(function () { // Timeline var _timeline = $('.timeline .data'); var _startTimeline = $('.timeline > div:first').data("year") - 1; var _endTimeline = $('.timeline > div:last').data("year"); var _difTimeline = _endTimeline - _startTimeline; var _widthTl = 120; $('.timeline').append('
'); timelineOffset = $('.timeline .bar').offset(); for( a = _startTimeline; a <= _endTimeline; a++) { n = a - _startTimeline; $('.timeline').append('
'); } _cnt = 0; _timeline.each(function(){ year = $(this).attr("data-year"); _text = $(this).html(); $('.year-' + year).append('

' + year + '

' + _text + '
'). addClass("active"); if( _cnt % 2 ) { $('.year-' + year).addClass("odd"); } //$('.year-' + ) _cnt++; }); $('.timeline-cont').append(''); $('.timeline-cont').append(''); _cnt = 0; _step = 4; _inViewport = 5; $('.timeline-cont a.next').click(function(ev){ ev.preventDefault(); _cnt += _step; if(_cnt > _difTimeline - _inViewport) { _cnt = _difTimeline - _inViewport; } _offset = _cnt * _widthTl; $('.timeline').animate({ left: -_offset }); }); $('.timeline-cont a.prev').click(function(ev){ ev.preventDefault(); _cnt -= _step; if(_cnt < 0) { _cnt = 0; } _offset = _cnt * _widthTl; $('.timeline').animate({ left: -_offset }); }); $('a[data-category]').click(function(e){ e.preventDefault(); var id = $(this).data("category"); $('div.category-item:not(.category-' + id + ')').hide(); $('div.category-item.category-' + id).show(); $("a[data-category], a.all-categories").removeClass("active"); $(this).addClass("active"); }); $('a.all-categories').click(function(e){ e.preventDefault(); $('div.category-item').show(); $("a[data-category]").removeClass("active"); $(this).addClass("active"); }) $('.gallery').Chocolat({ imageSize : 'contain', fullScreen: false, imageSelector: '.fancybox', loop: true }) $('.carousel-gallery').Chocolat({ imageSize : 'contain', fullScreen: false, imageSelector: '.fancybox', loop: true }) /* $('.product-images').Chocolat({ imageSize : 'contain', fullScreen: false, imageSelector: '.choco', loop: true }) */ $('.product-pics').Chocolat({ imageSize : 'contain', fullScreen: false, imageSelector: '.choco', loop: true }) $('.tabs > ul li a').click(function(e){ e.preventDefault(); $('.tabs > ul li a').removeClass("active"); $(this).addClass("active"); _trg = $(this).attr("href"); $(".tab").removeClass("active"); $(_trg).addClass("active"); }); $(".acc-title").click(function(e){ $(this).parent().toggleClass("active"); }); $('#contactFormSend').on('submit', function(evt){ evt.preventDefault(); var k = [ 'name', 'question' ], 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] +'"]'); if ( obj.val().length <= 1 ){ good = false; obj.addClass('error'); } } 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(); } }); var startSlider = $('.start-slider ').owlCarousel({ items: 1, autoplayHoverPause: false, autoplay: true, autoplayTimeout: 4000, animateIn: "fadeIn", animateOut: "fadeOut", loop: true, nav: false, dots: false }).addClass("owl-carousel"); //$('.start-slider .owl-dots').removeClass("disabled"); //$('.start-slider .owl-nav').removeClass("disabled"); $('.slider-nav .nav-right').click(function() { startSlider.trigger('next.owl.carousel'); }) $('.slider-nav .nav-left').click(function() { startSlider.trigger('prev.owl.carousel'); }) lightbox.option({ 'resizeDuration': 200, 'wrapAround': true }); var carouselGal = $('.carousel-gallery .carousel').owlCarousel({ items: 4, autoplayHoverPause: false, autoplay: true, autoplayTimeout: 4000, animateIn: "fadeIn", animateOut: "fadeOut", loop: true, nav: false, dots: false }).addClass("owl-carousel"); /* var gridImg = $('.grid').children('a') .children('.grid-item') .children(); for (var i=0; i<=gridImg.length; i++) { if (gridImg[i].prop('naturalHeight') >= 400) { gridImg[i].height = 300; gridImg[i].width = 200; } }*/ $('.grid-item img').each(function() { var image = new Image(); image.src = $(this).attr("src"); if ( image.naturalHeight > 350) { image.height = 300; image.width = 200; } }); });