var module; window.paceOptions = { ajax: { trackMethods: ['GET','POST'] } }; window.matchHeightRegistered = []; window.matchHeightOpts = { byRow: false, property: 'height' }; jQuery(document).ready(function($) { "use strict"; module = dget('rcVer','module'); Waves.init(); waves(); tooltips(); floatingInputs(); jQuery(document).delegate('#megamenu_copy_mobile .has-dropdown.simple-dropdown > a', 'click', function(e) { e.stopPropagation(); $(this).parent().find('.dropdown').toggle(); return false; }); $(window).on('change_listing_type listing_products_loaded',function() { correctRefreshLoadingObserver(); correctHeights(); }); $(window).on('listing_products_loaded quickViewOpen addToCartBoxOpen',function() { tooltips(); waves(); }); $(window).on('shippingLoaded modalLoad registerFormLoaded shippingDetailsLoaded ', function() { floatingInputs(); waves(); }); $(window).on('load', function() { setResponsiveImageSource(); $('body').removeClass('no-transitions'); $('body').removeClass('loader-visible'); $('#loader').fadeOut(700); }); $('select:not(.select_option_icons):not(.lang_select):not(.no-fancy)').fancySelect(); $('.lang_select').fancySelect(); $(window).on('inventoryLoaded modalLoad shippingLoaded registerFormLoaded shippingDetailsLoaded', function() { $('select:not(.select_option_icons):not(.select-cart-payments)').fancySelect(); }); /*$('.product-inside').on('click', function(e) { if($(e.target).is('a') || $(e.target).is('i')) { return; } window.location.href = $(this).data('url'); });*/ if($('#ajax_box_shopping_cart').length) { $.post('/ajax/cart/ajax_cart_box/').done(function(data) { $('#ajax_box_shopping_cart').html(data); jQuery('.remove-from-cart').on('click',function(e) { var pid = ''; var id = jQuery(this).attr('data-id'); var options = jQuery(this).attr('data-options'); pid = id + '_' + options; cart_del_ajax(pid) }); }); } if($('#ajax_box_loyalty').length) { ajax_box_loyalty_refresh(); } if(dget('rcVer','top') === true) { scrollToTop(); } $('[data-correct]').each(function(){ var group_name = $(this).data('correct'); if($.inArray(group_name,matchHeightRegistered) != -1) { return; } $('[data-correct="' + group_name + '"]').matchHeight(matchHeightOpts); matchHeightRegistered.push(group_name); }); $(window).on('viewport_changed', setResponsiveImageSource); $('.tabs').tabCollapse({ tabsClass: 'hidden-sm hidden-xs', accordionClass: 'visible-sm visible-xs' }); $(window).on('shown-tabs.bs.tabcollapse', function() { $('.tabs-line').tabsLine(); $('.tabs-animated-height').tabsAutoHeight(); }); $(window).on('shown-accordion.bs.tabcollapse', function() { $('.tabs-line').tabsLine('destroy'); $('.tabs-animated-height').tabsAutoHeight('destroy'); }); if(viewport_check.is_in(['md','lg'])) { $('.tabs-line').tabsLine(); $('.tabs-animated-height').tabsAutoHeight(); } }); function setResponsiveImageSource() { var vp = viewport_check.current(); jQuery('img[data-responsive]').each(function(){ var el = jQuery(this); if(vp == 'md' || vp == 'lg') { el.attr('src',el.data('md')); } if(vp == 'sm') { el.attr('src',el.data('sm')); } if(vp == 'xs') { el.attr('src',el.data('xs')); } }); } function dget(id,prop,isInt) { isInt = isInt != undefined ? isInt : false; if(jQuery('#'+id).length < 1 || jQuery('#'+id).data(prop) == undefined) return null; if(isInt) { return parseInt(jQuery('#'+id).data(prop)); } else { return jQuery('#'+id).data(prop); } } function tooltips() { jQuery('[data-toggle="tooltip"]').tooltip('destroy'); jQuery('[data-toggle="tooltip"]').tooltip({html:true}).on('hidden.bs.tooltip', function(){ jQuery(this).css('display',''); }); } function waves() { var waves = ['.button-light','.increase','.decrease']; var waves_light = ['.button-primary','.button-dark']; jQuery(waves).each(function(el) { Waves.attach(el); }); jQuery(waves_light).each(function(el) { Waves.attach(el,['waves-light']); }); } function floatingInputs() { jQuery('label.input-label').each(function() { var label = jQuery(this), input = label.children('input'), text = ''; if(label.hasClass('request') || label.parent().hasClass('request')) label.append('*'); if(jQuery(document.body).hasClass("no-material")) return; if(input.attr('data-placeholder') != undefined) return; if(input.attr('placeholder') != undefined) { text = input.attr('placeholder'); } else if(input.attr('data-placeholder') != undefined) { text = input.attr('data-placeholder'); } label.find('.label-text').remove(); label.append('' + text + ''); if(text != '') input.attr('data-placeholder', text); input.removeAttr('placeholder'); if(input.val() != '') label.addClass('hasContent'); input.on('focus', function() { label.addClass('hasContent'); }).on('blur', function() { if(input.val() == '') { label.removeClass('hasContent'); } }); }); } function scrollToTop() { jQuery('body').append('
'); setTimeout(function checkMessanger() { var messanger = document.querySelector('#fb-root > .fb-customerchat'); var scroll = document.getElementById('scrollToTop'); if (messanger) { scroll.style.bottom = 92 + 'px'; scroll.style.right = 28 + 'px'; } }, 1500) jQuery(window).on('scroll',function(){ if (jQuery(this).scrollTop() > 150) { jQuery('#scrollToTop').fadeIn(); } else { jQuery('#scrollToTop').fadeOut(); } }); if (jQuery(this).scrollTop() > 150) { jQuery('#scrollToTop').fadeIn(); } else { jQuery('#scrollToTop').fadeOut(); } jQuery('body').on('click','#scrollToTop', function() { jQuery('html, body').animate({scrollTop : 0},500); }); } startPinfoTimer(); function startPinfoTimer() { if(jQuery('#promotion-time-over').length > 0) { var element = jQuery('#promotion-time-over'); var time = document.getElementById('promotions_date_to_timestamp').innerHTML; time = time + '000'; // Update the count down every 1 second var x = setInterval(function() { // Get todays date and time var now = Date.now(); // Find the distance between now an the count down date var distance = time - now; // Time calculations for days, hours, minutes and seconds var days = Math.floor(distance / (1000 * 60 * 60 * 24)); var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000); hours = hours.toString(); minutes = minutes.toString(); seconds = seconds.toString(); if(hours.length == 1) { hours = '0' +hours; } if(minutes.length == 1) { minutes = '0' +minutes; } if(seconds.length == 1) { seconds = '0' +seconds; } // Display the result in the element with id="demo" document.getElementById("promotion-time-over").innerHTML = " " + days + " " + hours + ":" + minutes + ":" + seconds; // If the count down is finished, write some text if (distance < 0) { clearInterval(x); document.getElementById("promotion-time-over").innerHTML = "Zakończona"; } }, 1000); } } ;(function($) { $.fn.tabsLine = function(e) { if($(this).length <= 0) return; if(e === 'destroy'){ $('#tabsLine-' + $(this).data('tabsLine')).remove(); $(this).off('click.rc.tabs','[data-toggle="tab"]'); $(this).data('tabsLine',null); return this; } $(this).data('tabsLine', Math.floor((Math.random() * 13100) + 1)); var first_tab = $(this).find('li.active').children(); if(first_tab.length == 0) return; var line = $('
'); line.css({ 'width':first_tab.outerWidth()+'px', 'left':first_tab.position().left+'px', 'top':first_tab.closest('.tabs').height(), 'position':'absolute' }); $(this).append(line); $(this).on('click.rc.tabs','[data-toggle="tab"]',function() { var parent = $(this).parent(); line.css({ 'left':$(this).position().left+'px', 'width':$(this).outerWidth()+'px' }); }); return this; } $.fn.tabsAutoHeight = function(e) { if($(this).length <= 0) return; if(e === 'destroy') { $(this).off('show.bs.tab.rc'); $(this).removeClass('tahActivated'); $(this).find('.tab-content').css('height',''); return this; } $(this).addClass('tahActivated'); var tab_content = $(this).find('.tab-content'); tab_content.height(2000); var height = $(this).find('.tab-pane.active').outerHeight(true); tab_content.height(height); $(this).on('show.bs.tab.rc', $.proxy(function(e) { var prev = $($(e.relatedTarget).attr('href')); var next = $($(e.target).attr('href')); var height = next.outerHeight(true); $(this).find('.tab-content').css('height',height); },this)); } }(jQuery)); (function() { var dropdowns = document.querySelectorAll('[data-toggle="rc-dropdown"]') var cls = { dropdownContainer: 'rc-dropdown', dropdownMenu: 'rc-dropdown-menu', dropdownMenuLink: 'rc-dropdown-menu__link' } var hideDropdown = function (el, dropdownContainer, inResponsiveTable) { el._RcDropdownOpen = false el.setAttribute('aria-expanded', false) dropdownContainer.classList.remove(cls.dropdownContainer + '--open') inResponsiveTable && inResponsiveTable.removeAttribute('style') } var addTableResponsivePadding = function (dropdown, table) { requestAnimationFrame(function() { var parent = dropdown.parentNode var elRect = dropdown.getBoundingClientRect() var diff = (parent.offsetTop + dropdown.offsetTop + elRect.height) - table.getBoundingClientRect().height if (diff > 0) { table.style.paddingBottom = (diff + 5) + 'px' } }) } dropdowns.forEach(function(el) { var dropdownContainer = el.parentNode var dropdownMenu = dropdownContainer.querySelector('.' + cls.dropdownMenu) var inResponsiveTable = el.closest('.table-responsive') el._RcDropdownOpen = false var dropdownLinks = dropdownContainer.querySelectorAll('.' + cls.dropdownMenu + '__link') dropdownLinks.forEach(function(del) { del.addEventListener('click', function() { hideDropdown(el, dropdownContainer, inResponsiveTable) }) }) el.addEventListener('click', function(e) { e.preventDefault() if (el._RcDropdownOpen === true) { hideDropdown(el, dropdownContainer, inResponsiveTable) } else { inResponsiveTable && addTableResponsivePadding(dropdownMenu, inResponsiveTable) el._RcDropdownOpen = true el.setAttribute('aria-expanded', true) dropdownContainer.classList.add(cls.dropdownContainer + '--open') } }) document.addEventListener('click', function(e) { var target = e.target, closestMenu = target.closest('.' + cls.dropdownContainer) if (target !== dropdownContainer && (!closestMenu || (closestMenu && closestMenu !== dropdownContainer))) { hideDropdown(el, dropdownContainer, inResponsiveTable) } }) }) })(); window.addEventListener('load', function() { var invoice = document.getElementById('get_invoice'); var invoiceAccount = document.getElementById('send_address'); var companyRadio = document.getElementById('invoice[fv_type]_'); var personRadio = document.getElementById('invoice[fv_type]_1'); if (!invoice && !invoiceAccount) return var nipKlon = null var nipParent = null if (invoice) { var nipInput = document.getElementById('invoice[customers_nip]').parentNode if (nipInput) { nipParent = nipInput.parentNode nipKlon = nipInput.cloneNode(true) nipKlon.querySelector('input').disabled = false; } } function showHideNipInput () { if (invoice.checked === true && companyRadio.checked === true) { var nipInput = document.getElementById('invoice[customers_nip]'); if (!nipInput && nipKlon) { nipParent.appendChild(nipKlon) } setTimeout(nipRequired, 500) } else { var nipInput = document.getElementById('invoice[customers_nip]').parentNode nipInput && nipInput.remove() } } if (companyRadio && personRadio) { [invoice, companyRadio, personRadio].forEach(function(radioStar) { radioStar.addEventListener('click', showHideNipInput) }) } function nipRequired () { var nipInput = document.getElementById('invoice[customers_nip]'); if (nipInput) { nipInput.classList.add('fValidate[\'required\']'); nipInput.classList.add('fValidate[\'nip\']'); } } setTimeout(showHideNipInput); });