var APP = APP || {}; (function ($) { /* --------------------------------------------- Variables --------------------------------------------- */ var $window = $(window), $html = $('html'), $body = $('body'); /* --------------------------------------------- APP document Ready --------------------------------------------- */ APP.documentOnReady = { init: function () { APP.initialize.init(); } }; /* --------------------------------------------- APP document Load --------------------------------------------- */ APP.documentOnLoad = { init: function () { APP.initialize.preloader(); } }; /* --------------------------------------------- APP document Resize --------------------------------------------- */ APP.documentOnResize = { init: function () { var t = setTimeout(function () { }, 250); } }; /* --------------------------------------------- Scripts initialization --------------------------------------------- */ $(document).ready(APP.documentOnReady.init); $window.on('load', APP.documentOnLoad.init); $window.on('resize', APP.documentOnResize.init); /* ------------------------------------------------------------------------------------------------------------------ ############################################################################################################# ------------------------------------------------------------------------------------------------------------------ */ APP.initialize = { init: function () { APP.initialize.owl(); APP.initialize.select2(); APP.initialize.innerLinks(); APP.initialize.calendar(); APP.initialize.header(); APP.initialize.map(); APP.initialize.checkout(); }, /* --------------------------------------------- Inner links --------------------------------------------- */ innerLinks: function(){ $('.inner-link').each(function(){ var href = $(this).attr('href'); }); if($('.inner-link').length){ $('.inner-link').smoothScroll({ offset: -50, //offset: 0, speed: 750 }); } }, /* --------------------------------------------- Owl --------------------------------------------- */ owl: function(){ if ( $('#swiper-quote').length > 0 ) { var $owlQuote = $('#swiper-quote'); $owlQuote.owlCarousel({ nav:false, loop: true, margin:30, responsive:{ 0:{ items:1, margin:0, }, 640:{ items:2, }, 992:{ items:5, } } }); $(".swiper-quote-next").click(function () { $owlQuote.trigger('next.owl.carousel'); }); $(".swiper-quote-prev").click(function () { $owlQuote.trigger('prev.owl.carousel'); }); } if ( $('#swiper-team').length > 0 ) { var $owlTeam = $('#swiper-team'); $owlTeam.owlCarousel({ nav:false, loop: false, margin:0, responsive:{ 0:{ loop:true, items:1, margin:0, }, 992:{ items:3, } } }); $(".swiper-team-next").click(function () { $owlTeam.trigger('next.owl.carousel'); }); $(".swiper-team-prev").click(function () { $owlTeam.trigger('prev.owl.carousel'); }); } //Menu owl if ( $('#menu-slider').length > 0 ) { var $owlMenu = $('#menu-slider'); $owlMenu.owlCarousel({ nav:false, responsive:{ 0:{ items:1, loop: true }, 640:{ items:2, loop: true }, 992:{ loop: false, items:5, mouseDrag: false, touchDrag: false, pullDrag: false } } }); $(".swiper-menu-next").click(function () { $owlMenu.trigger('next.owl.carousel'); }); $(".swiper-menu-prev").click(function () { $owlMenu.trigger('prev.owl.carousel'); }); } //Special offer owl if ( $('#special-offer.owl-').length > 0 ) { var $owlSpecialOffer = $('#special-offer'); $owlSpecialOffer.owlCarousel({ nav:true, dots: true, margin:30, loop: false, dotsEach: true, stagePadding: 0, mouseDrag: true, touchDrag: true, pullDrag: true, navText: ['',''], responsive:{ 0:{ items:1, }, 640:{ items:3, }, 992:{ items:5, } } }); $(".soffer-next").click(function () { $owlSpecialOffer.trigger('next.owl.carousel'); }); $(".soffer-prev").click(function () { $owlSpecialOffer.trigger('prev.owl.carousel'); }); } //Special offer owl if ( $('#trainers-slider').length > 0 ) { var $owlTrainersSlider = $('#trainers-slider'); $owlTrainersSlider.owlCarousel({ nav:true, dots: true, margin:30, loop: false, dotsEach: true, mouseDrag: true, touchDrag: true, pullDrag: true, navText: ['',''], responsive:{ 0:{ items:1, }, 640:{ items:2, }, 992:{ items:3, } } }); $(".soffer-next").click(function () { $owlTrainersSlider.trigger('next.owl.carousel'); }); $(".soffer-prev").click(function () { $owlTrainersSlider.trigger('prev.owl.carousel'); }); } //Offer owl if ( $('#offer-slider').length > 0 ) { var $owlOffer = $('#offer-slider'); $owlOffer.children().each( function( index ) { $(this).attr( 'data-position', index ); }); $owlOffer.owlCarousel({ center: true, loop: true, nav:true, autoplay:true, autoplayTimeout:5000, responsive:{ 0:{ items:1, }, 640:{ items:1, }, 992:{ items:1, } } }); } }, /* --------------------------------------------- Select 2 --------------------------------------------- */ select2: function () { $('select:not(.phpdebugbar-datasets-switcher)').select2({ minimumResultsForSearch : -1, width: 'resolve', dropdownAutoWidth : true }); // select filter $('select[data-filter-for]').on('change', function() { var filterFor = $(this).attr('data-filter-for'); var val = $(this).val(); $('#' + filterFor).find('div[data-filter]').removeClass('active'); $('#' + filterFor).find('div[data-filter="' + val + '"]').addClass('active'); $(this).blur(); }); }, /* --------------------------------------------- Preloader --------------------------------------------- */ preloader: function () { if ( $("div").is("#loader") ){ $("#loader").fadeOut(1200, function() { $("body").removeClass("loading"); $("body").addClass("loaded"); }); } else { $("body").removeClass("loading"); $("body").addClass("loaded"); } }, /* --------------------------------------------- Delay Links --------------------------------------------- */ delayLinks: function(){ $("a:not([target='_blank']):not([href^='#']):not([href^='/'])").on("click", function (e) { e.preventDefault(); var goTo = this.getAttribute("href"); $("body").addClass("loading"); $("#loader").fadeIn(900, function() {}); setTimeout(function(){ window.location = goTo; },2000); }); }, calendar: function() { if ($('#clndr').length > 0) { var today = moment();//.add(0,'days'); var startDate = moment(today).add(0,'days'); var endDate = moment(today).add(365, 'days'); var clndr = $('.clndr').clndr({ lengthOfTime: { months: 1, interval: 1 }, //daysOfTheWeek: ['N', 'Pn', 'Wt', 'Śr', 'Cz', 'Pt', 'So'], //weekOffset: 0, startWithMonth: szkolenia[0].date, events: szkolenia, adjacentDaysChangeMonth: false, constraints: { startDate: startDate.format('YYYY-MM-DD'), endDate: endDate.format('YYYY-MM-DD') }, clickEvents: { click: function (target) { }, nextInterval: function () { }, previousInterval: function () { }, onIntervalChange: function () { } }, template: $('#template-calendar-months').html(), forceSixRows: false, }); // helpers var temp = []; var edit_mode = false; var edit_all_mode = false; var edit_day_change, edit_day_accident, edit_day_recompense, order_all_days; var week_mode = false; var prefix = ''; var dateToday = new Date(); order_all_days = szkolenia.map(function( day ){ return day.date }); } $('#calendarFilters').change(function(){ var form = document.getElementById("calendarFilters"); var filterData = new FormData( form ); if(filterData.get('rodzaj') == 2) { $('select#lokalizacja').prop('disabled', true); } else { $('select#lokalizacja').prop('disabled', false); } $.ajax({ url: '/kalendarz-szkolen/filter', type: "POST", data: filterData, processData: false, contentType: false, success: function (obj) { var szkolenia = obj; clndr.setEvents(szkolenia); clndr.setIntervalStart(szkolenia[0].date); } }) }); }, checkout: function () { $('#submitbutton').on('click', function () { var empty = false; var zgody = false; $('input[name^="imie"]').each(function () { if($(this).val() == "") { empty = true; } }); $('input[name^="zgoda"]').each(function () { if($(this).val() == "") { zgody = true; } }); var zgoda_1 = false; if($('input[name="zgoda_1"]').prop('checked')) { zgoda_1 = true; } if(zgoda_1 != true) { alert("Zaakceptuj wymagane zgody w formularzu"); return false; } if(empty) { alert("Uzupełnij dane wszystkich uczestników"); return false; } if(zgody) { alert("Zaakceptuj wymagane zgody w formularzu"); return false; } }); $('#contactsubmit').on('click', function () { var zgoda_1 = false; var zgoda_2 = false; if($('input[name="zgoda_1"]').prop('checked')) { zgoda_1 = true; } if($('input[name="zgoda_2"]').prop('checked')) { zgoda_2 = true; } if(zgoda_1 != true || zgoda_2 != true) { alert("Zaakceptuj wymagane zgody w formularzu"); return false; } }); if ($('select[name="wojewodztwo"]').val() == "") { $('select[name="doradca"]').html(''); } $('select[name="wojewodztwo"]').on('change', function () { var region = this.value; var link = '/koszyk/pobierz-doradcow/region/' + region if (region == undefined) $('select[name="doradca"]').html(''); else { $.ajax({ url: link, context: document.body, dataType: "JSON", success: function (obj) { var options = ''; $.each(obj.regions, function (key, value) { options = options + '' }); $('select[name="doradca"]').html(options); } }) } }); $('.remove-from-basket').on('click', function () { var container = $(this).closest('.remove-from-basket'); var row = $(container).closest('.card'); var link = '/koszyk/usun/' + $(this).attr('rel'); $.ajax({ url: link, context: document.body, dataType: "JSON", success: function (obj) { $(row).remove(); $('.header .basket .basket-count').html(obj.basketCount); } }) return false; }); $('.basket-item .add-user').on('click', function () { var container = $(this).closest('.basket-item'); var key = $(container).attr('data-key'); var rowHtml = '
'; $('.users', container).append(rowHtml); przelicz_uczestnikow(container); return false; }); $('.basket-item').delegate('.remove-user','click',function(){ var container = $(this).closest('.basket-item'); $(this).closest('.user').remove(); przelicz_uczestnikow(container); return false; }); function przelicz_uczestnikow(container) { var n = $('.users .user',container).length; if (n > 1) $('.users-count',container).html(n+' uczestników'); else $('.users-count',container).html('1 uczestnik'); if (n > 2) $('.add-user', container).hide(); else $('.add-user', container).show(); } }, /* --------------------------------------------- Navbar --------------------------------------------- */ header: function () { var $header= $('.header'); if ( $(window).scrollTop() > 100 ){ $header.addClass("header-sticky"); } //sticky navbar scroll $(window).scroll(function() { if ( $(this).scrollTop() > 100 ){ $header.addClass("header-sticky"); } else{ $header.removeClass("header-sticky"); } }); $('#triger-menu').on('click', function(){ $('#offCanvas').addClass('open'); $body.addClass('canvas-is-open'); $('.usher-sidebar').removeClass('active'); }); $('#offcanvas-close').on('click', function(){ $('#offCanvas').removeClass('open'); $body.removeClass('canvas-is-open'); }); $('.trigger-sidebar').on('click', function(){ $('.usher-sidebar').toggleClass('active'); }); $('.usher-sidebar .sidebar-close').on('click', function(){ $('.usher-sidebar').removeClass('active'); }); $(".usher-sidebar").swipe( { swipe:function(event, direction, distance, duration, fingerCount, fingerData) { if (direction == "left") { $('.usher-sidebar').removeClass('active'); if ( $('.usher-sidebar').is('active') ) { $('.usher-sidebar').removeClass('active'); } } } }); $(".offcanvas").swipe( { swipe:function(event, direction, distance, duration, fingerCount, fingerData) { if (direction == "left") { if ( $body.is('.canvas-is-open') ) { $('#offCanvas').removeClass('open'); $body.removeClass('canvas-is-open'); } } } }); }, /* --------------------------------------------- Map -----------------------------------------------*/ map: function() { if($('#map').length > 0) { var map = new google.maps.Map(document.getElementById('map'), { zoom: 6, center: {lat: 52.148077, lng: 19.700319} }); var marker = new google.maps.Marker({ map: map, // Define the place with a location, and a query string. place: { location: {lat: 54.362761, lng: 18.472807}, query: 'Akademia Klima-Therm, Gdańsk, Budowlanych 48' } }); var marker2 = new google.maps.Marker({ map: map, // Define the place with a location, and a query string. place: { location: {lat: 50.268099, lng: 19.006007}, query: 'Akademia Klima-Therm, Chorzowska 108, Katowice' } }); var marker3 = new google.maps.Marker({ map: map, // Define the place with a location, and a query string. place: { location: {lat: 52.235740, lng: 21.085818}, query: 'Akademia Klima-Therm, Ostrobramska 101A, Warszawa' } }); // Construct a new InfoWindow. var infoWindow = new google.maps.InfoWindow({ content: 'Akademia Klima-Therm, Gdańsk, Budowlanych 48' }); // Opens the InfoWindow when marker is clicked. marker.addListener('click', function() { infoWindow.open(map, marker); }); // Construct a new InfoWindow. var infoWindow2 = new google.maps.InfoWindow({ content: 'Akademia Klima-Therm, Chorzowska 108, Katowice' }); // Opens the InfoWindow when marker is clicked. marker2.addListener('click', function() { infoWindow2.open(map, marker2); }); // Construct a new InfoWindow. var infoWindow3 = new google.maps.InfoWindow({ content: 'Akademia Klima-Therm, Ostrobramska 101A, Warszawa' }); // Opens the InfoWindow when marker is clicked. marker3.addListener('click', function() { infoWindow3.open(map, marker3); }); } }, }; })(jQuery); //init scroll $(window).on('load', function(){ if(!(/Android|iPhone|iPad|iPod|BlackBerry|Windows Phone/i).test(navigator.userAgent || navigator.vendor || window.opera)){ var s = skrollr.init({ forceHeight: false, }); } }); $.fn.isInViewport = function () { let elementTop = $(this).offset().top; let elementBottom = elementTop + $(this).outerHeight(); let viewportTop = $(window).scrollTop(); let viewportBottom = viewportTop + $(window).height(); return elementBottom > viewportTop && elementTop < viewportBottom; }; $(window).scroll(function () { if($('.counter').length > 0) { if ($('.counter ').isInViewport()) { $('.counter').each(function() { var $this = $(this), countTo = $this.attr('data-count'); $({ countNum: $this.text()}).animate({ countNum: countTo }, { duration: 1500, easing:'linear', step: function() { $this.text(Math.floor(this.countNum)); }, complete: function() { $this.text(this.countNum); //alert('finished'); } }); }); } else { console.log('No success.') } } }); function exeAjax(link) { $.ajax({ url: link, context: document.body, dataType: "JSON", success: function (obj) { var url= "/koszyk"; window.location = url; } }) } // form-group-checkout labels function inputCheckout() { $('.form-group-checkout').each(function(){ var formElem = $(this).find('.form-control-checkout'); if ( formElem.val().length ){ $(this).addClass('has-value'); } else{ $(this).removeClass('has-value'); } }); } function selectCheckout() { $('.form-group-checkout-select').each(function () { var formElem = $(this).find('select'); if (formElem.val() !== "") { $(this).addClass('has-value'); } else { $(this).removeClass('has-value'); } }); } inputCheckout(); selectCheckout(); $('.form-group-checkout .form-control-checkout').on('change keyup paste', function () { inputCheckout(); }); $('.form-group-checkout-select select').on('change focus', function () { selectCheckout(); });