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 () { $.fn.extend({ animateCss: function(animationName, callback) { var animationEnd = (function(el) { var animations = { animation: 'animationend', OAnimation: 'oAnimationEnd', MozAnimation: 'mozAnimationEnd', WebkitAnimation: 'webkitAnimationEnd', }; for (var t in animations) { if (el.style[t] !== undefined) { return animations[t]; } } })(document.createElement('div')); this.addClass('animated ' + animationName).one(animationEnd, function() { $(this).removeClass('animated ' + animationName); if (typeof callback === 'function') callback(); }); return this; }, }); $('.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 }) $('.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, animateOut: 'fadeOut', animateIn: 'fadeIn', loop: true, nav: false, dots: true, navText: ['',''] }).addClass("owl-carousel owl-theme"); /*var elementOwl = $('.owl-item.active'); if($('.owl-item').hasClass('active')) { var owlFunc = elementOwl.find('.slider-text').animateCss('bounceIn'); setInterval(4000,owlFunc); }*/ $('.slider-nav .nav-right').click(function() { startSlider.trigger('next.owl.carousel'); }) $('.slider-nav .nav-left').click(function() { startSlider.trigger('prev.owl.carousel'); }) $('.carousel-gallery .carousel').owlCarousel({ responsive: { 0: { items: 1 }, 700: { items: 1, margin: 10 }, 1000: { items: 1, margin:10 }, 1200: { items: 1, margin:20 } }, autoplay: true, autoplayHoverPause: false, autoplayTimeout: 2000, dots: true, loop: true, thumbs: false }).addClass("owl-carousel owl-theme"); $('.carousel-gallery .small').owlCarousel({ responsive: { 0: { items: 2 }, 700: { items: 4, margin: 10 }, 1000: { items: 7, margin:20 }, 1200: { items: 7, margin:30 } }, autoplay: true, autoplayHoverPause: false, autoplayTimeout: 2000, dots: false, loop: true, thumbs: false }).addClass("owl-carousel"); if($('.icons-carousel').attr('data-count') >= 5 ) { $('.icons-carousel-wrap').owlCarousel({ responsive: { 0: { items: 1 }, 700: { items: 2, margin: 10 }, 1000: { items: 3, margin:10 }, 1200: { items: 4, margin:15 } }, autoplay: true, autoplayHoverPause: false, autoplayTimeout: 2000, dots: false, loop: true, nav: false, navText: ['‹','›'], thumbs: false }).addClass("owl-carousel owl-theme"); } else if ($('.icons-carousel').attr('data-count') == 4 ) { $('.icons-carousel-wrap').owlCarousel({ responsive: { 0: { items: 1 }, 700: { items: 2, margin: 10 }, 1000: { items: 3, margin:10 }, 1200: { items: 4, margin:15 } }, autoplay: false, autoplayHoverPause: false, autoplayTimeout: 50000, dots: false, loop: false, nav: false, thumbs: false }).addClass("owl-carousel"); } else { $('.icons-carousel-wrap').addClass('flex-gallery'); } $('.products-gallery .carousel').owlCarousel({ responsive: { 0: { items: 1 }, 700: { items: 3, margin: 10 }, 1000: { items: 4, margin:10, nav: true } }, autoplay: true, autoplayHoverPause: false, autoplayTimeout: 4000, nav: true, navText: ['‹','›'], loop: true }).addClass("owl-carousel"); $('.oferta-slider').owlCarousel({ responsive: { 0: { items: 1 }, 500: { items: 2, margin: 5 }, 750: { items: 3, margin: 10 }, 1200: { items: 4, margin:40 } }, autoplay: true, autoplayHoverPause: false, autoplayTimeout: 3500, dots: false, nav: true, loop: true, navText: ['',''], thumbs: false }).addClass("owl-carousel owl-theme"); //if($('.realizacje-start > *').length > 3 ) { $('.realizacje-start').owlCarousel({ responsive: { 0: { items: 1, loop: true }, 400: { items: 2, margin: 10, loop: true }, 700: { items: 3, margin: 10, loop: false }, 1200: { items: 3, margin:10, loop: false } }, autoplay: true, autoplayHoverPause: false, autoplayTimeout: 12500, dots: false, nav: true, navText: ['‹','›'], thumbs: false }).addClass("owl-carousel owl-theme"); if ($(window).innerWidth() < 540 ) { var button = $('.realizacje .realizacje-header .button'); button.appendTo('.realizacje').addClass('button-fix').css({ width:300, margin:'15px auto'}); } //} //scroll to element $(".anchor").click(function() { $('html,body').animate({ scrollTop: $(".products").offset().top}, 'slow'); }); $("#anchor").click(function() { $('html,body').animate({ scrollTop: $(".typical-content.certyficate.center").offset().top}, 'slow'); }) /// //parallax animation $('.p-layer-1').animateCss('slideInRight'); //$('.p-layer-2').animateCss('slideInRight'); // $('.products-item').click(function(e) { e.stopPropagation(); e.preventDefault(); var elem = $(this).find('.extra-option'); //console.log(elem); $('body').addClass("blocked"); $('.offer-modal').addClass("on"); $('.offer-modal .content').html( elem.html() ); setTimeout(function(){ $('.offer-modal').addClass("animated"); var wh = $(window).height(); var ch = $('.offer-modal .content').height(); console.log(ch + ' x ' + wh); if( ch < wh - 200 ) { // add upper margin var marginTop = (wh - ch ) / 2 - 50; $('.offer-modal .content').css("margin-top", marginTop); } }, 100); $('.offer-modal .close-btn, .offer-modal').click(function(ev){ ev.preventDefault(); if( $(this).hasClass("close-btn") || $(ev.target).hasClass("offer-modal") ){ $('body').removeClass("blocked"); $('.offer-modal').removeClass("animated").removeClass("on"); } }); /* $('.products-item.clicked').find('.extra-option.open').slideUp(function() { $(this).appendTo($thisParent).removeClass('open'); }); $(this).addClass("clicked"); var $thisParent = $(this); var elem = $(this).find('.extra-option'); var position = $(this).attr('data-position'); console.log("position: " + position); var move = function (elemPosition) { var divide = elemPosition / 3; var divideMod = elemPosition % 3; var rest = divide - divideMod; console.log("reszta z dzielenia: " + rest); var endPosition; if (divideMod === 0 ) { endPosition = parseInt(elemPosition) - 1; console.log("gdzie wstawic: " + endPosition); return endPosition; //3rd position in row } else if (elemPosition == 2 || elemPosition == 5 || elemPosition == 8 ) { endPosition = elemPosition; console.log("gdzie wstawic: " + endPosition); return elemPosition //2nd position in row } else if (divide === 0 || rest <= 0.4) { endPosition = parseInt(elemPosition) + 1; console.log("gdzie wstawic: " + endPosition); return endPosition; //1st position in row } }; $(elem).slideDown(); if (position >= (parseInt($('.products-item').length) - 2 )) { $(elem).insertAfter($('.products-item')[parseInt($('.products-item').length) - 1]); } else { $(elem).insertAfter($('.products-item')[move(position)]); } if(!$(elem).hasClass('open')) { $(elem).addClass('open'); } else { $(elem).slideUp(function() { $(this).appendTo($thisParent).removeClass('open'); }); }; $('html,body').animate({ scrollTop: $(".extra-option.open").offset().top}, 'slow'); $('.close').click(function () { if($(elem).hasClass('open')) { $(elem).slideUp(function() { $(this).appendTo($thisParent).removeClass('open'); }); } }); $(".products-item, .extra-option.open").on('click', function (e) { e.stopPropagation(); }); $(document).click(function(e) { $('.extra-option.open').slideUp(function() { $(this).appendTo($thisParent).removeClass('open'); }); }) */ }); $(".extra-gallery-start").owlCarousel({ items: 1, dots:true }).addClass('owl-carousel'); // 1) ASSIGN EACH 'DOT' A NUMBER dotcount = 1; var dot = $('.extra-gallery-start .owl-dot'); dot.each(function() { $( this ).addClass( 'dotnumber' + dotcount); $( this ).attr('data-info', dotcount); dotcount=dotcount+1; }); // 2) ASSIGN EACH 'SLIDE' A NUMBER slidecount = 1; $('.extra-gallery-start .owl-item').not('.cloned').each(function() { $( this ).addClass( 'slidenumber' + slidecount); slidecount=slidecount+1; }); // SYNC THE SLIDE NUMBER IMG TO ITS DOT COUNTERPART (E.G SLIDE 1 IMG TO DOT 1 BACKGROUND-IMAGE) dot.each(function() { grab = $(this).data('info'); slidegrab = $('.slidenumber'+ grab +' img').attr('src'); //console.log(slidegrab); $(this).css("background-image", "url("+slidegrab+")"); }); });