var google = true; $(document).ready(function(){ $('form#badanie-form button, .rezerwacja').click(function(e){ e.preventDefault(); $('#reservation-form').toggleClass("on"); $('#reservation-form').click(function(e){ if(e.target.id == 'reservation-form'){ $(this).removeClass('on'); } }); $('#reservation-form .cancel').click(function(e){ $('#reservation-form').removeClass('on'); }); }); $('#inlineDatepicker').datepicker({ onSelect : function(date) { $('#reservation-form [name="data"]').val( date ); $('#inlineDatepickerInput').val( date ); $('#selected-exam-date').text( date +'*' ); }, dateFormat: 'yy-mm-dd', dayNamesMin: [ "Ni", "Po", "Wt", "Śr", "Cz", "Pi", "So" ], dayNames: [ "Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota" ], dayNamesShort: [ "Nie", "Pon", "Wto", "Śro", "Czw", "Pią", "Sob" ], monthNames: [ "Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień" ], minDate : (new Date()) }); $('input.calendar').datepicker({ onSelect : function(date) { $('#inlineDatepickerInput').val( date ); $('#selected-exam-date').text( date +'*' ); }, dateFormat: 'yy-mm-dd', dayNamesMin: [ "Ni", "Po", "Wt", "Śr", "Cz", "Pi", "So" ], dayNames: [ "Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota" ], dayNamesShort: [ "Nie", "Pon", "Wto", "Śro", "Czw", "Pią", "Sob" ], monthNames: [ "Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień" ], minDate : (new Date()) }); $('#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; // } if ( $(this).find('[name="phone"]').val().replace(/[^\d]/gi, '').length < 9 && /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test( $(this).find('[name="phone"]').val() ) === false ){ $(this).find('[name="phone"]').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(); } }); // Zabiegaj linkom # $('a[href=#]').click(function(e){ e.preventDefault(); }); }); $(window).load(function(){ if( $('.owl_camera_slider > *').length > 1 ) { $('.owl_camera_slider').owlCarousel({ items:1, loop: true, lazyLoad : true, nav : false, dots: true, autoplay: true, autoplayTimeout: 5000, animateIn: 'fadeIn', animateOut: 'fadeOut' }); } $('.offer-carousel').owlCarousel({ navText: ['',''], items:3, loop: true, dots: false, responsive:{ 0:{ items:1, nav:false }, 600:{ items:2, nav:false }, 1000:{ items:3, nav:true } } }); $('.inverse-carousel').owlCarousel({ autoWidth: true, autoplay: true, autoplayTimeout: 2000, autoplayHoverPause: true, margin:10, loop: true, nav : false, dots: true, responsive:{ 0:{ items:1, nav:true }, 600:{ items:3, nav:false }, 1000:{ items:4, nav:true }, 1200: { items:5, nav:true, center:true } } }); }); $(document).on('submit', '#reservation-form form', function(evt){ evt.preventDefault(); var k = [ 'name', 'data', 'time' ], 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="email"]').val() ) == false ){ $(this).find('[name="email"]').addClass('error'); good = false; } // if ( /^[\d]{2}:[\d]{2}$/.test( $(this).find('[name="time"]').val() ) == false ){ // $(this).find('[name="time"]').addClass('error'); // good = false; // } if ( $(this).find('[name="phone"]').val().replace(/[^\d]/, '').length < 9 ){ $(this).find('[name="phone"]').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(); alert("Formularz został wysłany.\nDziękujemy!"); $(this).removeClass('on'); $(this).find('input[name="email"]').val(''); $(this).find('input[name="phone"]').val(''); $(this).find('input[name="name"]').val(''); $(this).find('textarea[name="message"]').val(''); $(this).find('input[type="checkbox"]').prop('checked', false); } else { $(this).find('p.ajaxInfo.error_send').show(); alert("Wystąpił błąd i nie udało się wysłać formularza.\nProsimy spróbować ponownie."); } }.bind(this)); } else { $(this).find('p.ajaxInfo.error').show(); } });