// On Document Ready initialise the options jQuery(document).ready(function($){ "use strict"; /* Mobile Navigation */ $(function(){ $('#sub-nav').slicknav({ label: '', duration: 1000, easingOpen: "easeOutBounce", //available with jQuery UI closeOnClick:true }); }); /* Mobile Navigation */ /* Tool Tip */ $("[data-toggle=tooltip]").tooltip(); /* Tool Tip */ /* Back to top */ var offset = 250; var duration = 300; jQuery(window).scroll(function() { if (jQuery(this).scrollTop() > offset) { jQuery('.back-to-top').fadeIn(duration); } else { jQuery('.back-to-top').fadeOut(duration); } }); jQuery('.back-to-top').click(function(event) { event.preventDefault(); jQuery('html, body').animate({scrollTop: 0}, duration); return false; }) $('ul.tabs li').click(function(){ var tab_id = $(this).attr('data-tab'); $('ul.tabs li').removeClass('current'); $('.tab-content').removeClass('current'); $(this).addClass('current'); $("#"+tab_id).addClass('current'); }) function topBarSize() { var el = $('.top-bar .container'); el.css( { 'display' : 'none', 'height' : 'auto' }).attr('data-height', el.height()).attr('style', 'height: 0;').parent().removeClass('open'); } $('.top-bar .close').on('click', function() { var el = $('.top-bar'); var child = $('.top-bar .container'); el.toggleClass('open'); if( el.hasClass('open') ) { child.height(child .attr('data-height')); } else { child.attr('style', 'height: 0;'); } }); topBarSize(); $(window).resize(function() { topBarSize(); }); /************************************************************* Contact Form Start **************************************************************/ $('#contact_form').validate({ rules: { name: { minlength: 2, required: true }, phone: { required: true, }, email: { required: true, email: true }, subject: { minlength: 2, required: true }, message: { minlength: 2, required: true } }, messages: { name: { minlength: "Proszę wpisać minimum {0} znaki.", required: "Proszę podać swoje imię i nazwisko.", }, phone: { required: "Proszę podać swój numer telefonu.", }, email: { required: "Proszę podać swój adres e-mail.", email: "Podany adres e-mail jest nieprawidłowy.", }, subject: { minlength: "Proszę wpisać minimum {0} znaki.", required: "Proszę uzupełnić to pole.", }, message: { minlength: "Proszę wpisać minimum {0} znaki.", required: "Proszę uzupełnić to pole.", } }, highlight: function (element) { $(element).closest('.control-group').removeClass('success').addClass('error'); }, success: function (element) { element .html('').addClass('valid') .closest('.control-group').removeClass('error').addClass('success'); }, submitHandler: function (form) { // do other stuff for a valid form $.post('\x2Fkontakt\x2Fsubmit', $("#contact_form").serialize(), function (data) { // action file is here }); } }); }); // End DOM Ready Function // WOW Init Reveal Animation wow = new WOW( { animateClass: 'animated', offset: 100 } ); wow.init(); // // wow end (function($){ $.fn.serializeObject = function(){ var self = this, json = {}, push_counters = {}, patterns = { "validate": /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/, "key": /[a-zA-Z0-9_]+|(?=\[\])/g, "push": /^$/, "fixed": /^\d+$/, "named": /^[a-zA-Z0-9_]+$/ }; this.build = function(base, key, value){ base[key] = value; return base; }; this.push_counter = function(key){ if(push_counters[key] === undefined){ push_counters[key] = 0; } return push_counters[key]++; }; $.each($(this).serializeArray(), function(){ // skip invalid keys if(!patterns.validate.test(this.name)){ return; } var k, keys = this.name.match(patterns.key), merge = this.value, reverse_key = this.name; while((k = keys.pop()) !== undefined){ // adjust reverse_key reverse_key = reverse_key.replace(new RegExp("\\[" + k + "\\]$"), ''); // push if(k.match(patterns.push)){ merge = self.build([], self.push_counter(reverse_key), merge); } // fixed else if(k.match(patterns.fixed)){ merge = self.build([], k, merge); } // named else if(k.match(patterns.named)){ merge = self.build({}, k, merge); } } json = $.extend(true, json, merge); }); return json; }; })(jQuery);