(function ($) {
$('body').on('click', '.category_li.show_less', function (e) {
$('html, body').animate({
scrollTop: $('#category_boxes').offset().top - 300
}, 500, 'linear');
});
$('body').on('click', '.category_li.more_cat', function(e){
e.preventDefault();
var el = $(this);
var less_or_more;
if(el.hasClass('show_less')){
less_or_more = 1;
} else if (el.hasClass('show_less_2')){
less_or_more = 2;
} else {
less_or_more = 0;
}
$('.category_boxes').addClass('waiting');
$.ajax({
type: 'POST',
url: diamond.ajax_url,
data: { action: 'category_more', less_more: less_or_more},
success: function (result) {
$('.category_boxes').removeClass('waiting');
$('.category_boxes').html(result);
},
error: function () {
alert('Błąd');
}
});
});
$(".wybor_woj li").on('click', function(){
$('.wybor_woj li').removeClass('active');
$(this).addClass('active');
var this_woj = $(this).data('woj');
console.log(this_woj);
$('.gallery_woj_row').addClass('waiting');
$.ajax({
type: 'POST',
url: diamond.ajax_url,
data: { action: 'gallery_woj', woj: this_woj },
success: function (result) {
$('.gallery_woj_row').removeClass('waiting');
$('.gallery_woj_row').html(result);
if (typeof doLightBox !== 'undefined' && typeof jQuery !== 'undefined') { doLightBox(); }
},
error: function () {
alert('Błąd');
}
});
});
})(jQuery);
// fixed header with less scroll
(function ($) {
jQuery(function ($) {
var offset = 10;
var $header = $('#main-header');
// Override the addClass to prevent fixed header class from being added before offset reached
var addclass = $.fn.addClass;
$.fn.addClass = function () {
var result = addclass.apply(this, arguments);
if ($(window).scrollTop() < offset) {
$header.removeClass('et-fixed-header');
}
return result;
}
// Remove fixed header class initially
$header.removeClass('et-fixed-header');
// Create waypoint which adds / removes fixed header class when offset reached
$('body').waypoint({
handler: function (d) {
$header.toggleClass('et-fixed-header', (d === 'down'));
},
offset: -offset
});
});
$('#menuToggle input').on('change', function () {
if ($(this).is(':checked')) {
$('#top-menu').addClass('open_mobile');
} else {
$('#top-menu').removeClass('open_mobile');
}
});
// if ($('body').hasClass('page-id-11')){
// $('#top-header #et-secondary-nav').append('
');
// }
// if ($(window).width() < 960) {
// $('.menu-item-2514').append('+');
// setTimeout(function () {
// $('.mobile_open').on('click', function(){
// $(this).parent().toggleClass('open_menu');
// if ($('.menu-item-2514').hasClass('open_menu')){
// $('.mobile_open').text('-');
// }else{
// $('.mobile_open').text('+');
// }
// });
// }, 2000);
// $('.menu-item-2514 .menu-item-has-children').append('+');
// }
})(jQuery);
function wc_price( price ){
price = parseFloat( price ).toFixed( 2 );
return `${price} zł`;
}
function price_without_tax( price ){
return wc_price( price / 1.23 );
}
function c2d( input ){
if( typeof input != 'string' ) return input;
return input.replace( ',', '.' );
}
(function ($) {
$('.need_fv input').change(function () {
if ($(this).is(":checked")) {
$(' .billing_invoice_field').show();
$('#billing_nip').attr('disabled', true);
var wrapper = $('#billing_nip').closest('.form-row').removeClass('woocommerce-invalid');
} else {
$('#billing_nip').attr('disabled', false);
var wrapper = $('#billing_nip').closest('.form-row');
if (!checkNIP($('#billing_nip').val()) && $('#billing_nip').val() != '') {
wrapper.addClass('woocommerce-invalid');
}
}
});
$(document).ready(function () {
if ($('.need_fv').find('.input-checkbox').is(":checked")) {
$('#billing_nip').attr('disabled', true);
$('.billing_invoice_field').show();
} else {
$('.billing_invoice_field').hide();
$('#billing_nip').attr('disabled', false);
}
});
$('body').on('change', '#billing_nip, #billing_invoice_nip', function () {
let val = $(this).val();
val = val.replace(/[^0-9]+/, '');
$(this).val(val);
var wrapper = $(this).closest('.form-row');
if (checkNIP($(this).val()) || $(this).val() == '' && $(this).attr('id') == 'billing_nip') {
wrapper.addClass('woocommerce-validated'); // success
} else {
wrapper.addClass('woocommerce-invalid'); // error
}
});
$('body').on('change', '#billing_invoice_name, #billing_invoice_address, #billing_invoice_city', function () {
var wrapper = $(this).closest('.form-row');
if ($(this).val().length < 3) {
wrapper.addClass('woocommerce-invalid'); // error
invalid = true;
} else {
wrapper.addClass('woocommerce-validated'); // success
}
});
$('body').on('blur change', '#billing_invoice_postcode', function () {
var wrapper = $(this).closest('.form-row');
let code = $(this).val().replace(/[^0-9]+/, '');
console.log(code);
if (code.length != 5) {
wrapper.addClass('woocommerce-invalid'); // error
} else {
wrapper.addClass('woocommerce-validated'); // success
}
});
$(document.body).on('checkout_error', function () {
$('.woocommerce-NoticeGroup-checkout strong').each(function () {
let oi = $(this).text().replace('Billing', '');
$(this).text(oi)
});
if ($('#billing_invoice').is(":checked")) {
$('#billing_invoice_name, #billing_invoice_address, #billing_invoice_city, #billing_invoice_nip').trigger('change');
} else {
$('.billing_invoice_field ').removeClass('woocommerce-invalid');
}
});
if ($('#shipping_method li input#shipping_method_0_local_pickup10').is(":checked")){
$('.woocommerce-shipping-fields').hide();
$('.woocommerce-shipping-fields input').attr("disabled", true);
}
$(document).on('change', '.shipping_method', function () {
if ($('#shipping_method li input#shipping_method_0_local_pickup10').is(":checked")){
$('.woocommerce-shipping-fields').hide();
$('.woocommerce-shipping-fields input').attr("disabled", true);
}else{
$('.woocommerce-shipping-fields').show();
$('.woocommerce-shipping-fields input').attr("disabled", false);
}
});
})(jQuery);
function checkNIP(str) {
str = str.replace(/[^0-9]+/, '');
if (str.length !== 10) {
return false;
}
arrSteps = [6, 5, 7, 2, 3, 4, 5, 6, 7];
intSum = 0;
for (let i = 0; i < 9; i++) {
intSum += arrSteps[i] * str[i];
}
int = intSum % 11;
intControlNr = int === 10 ? 0 : int;
if (intControlNr == str[9]) {
return true;
}
return false;
}
(function ($) {
$('.mobile_cat_open').on('click tap', function(){
$('.under_head').toggleClass('on_click');
});
if ($('body').hasClass('page-id-2840')){
$('.menu-item-2847 > a').attr('href','/oferta-dla-klientow-hurtowych/');
}
$( document ).ready( function(){
console.log('zastosowanie');
setTimeout(function(){
$('.widget-area .filter .filter__item .filter__title').each(function(){
var nn = $(this).text();
nn.toString();
if (nn.includes('Tag')){
$(this).text('Zastosowanie');
}
});
}, 1500);
});
$('.wybor_woj li').first().trigger('click');
}) (jQuery);
(function ($) {
const $quantity = $( 'input[name="quantity"]' );
const variants = $( '#variant-data' ).data( 'variants' );
const shipping = $( '#variant-data' ).data( 'shipping' );
const $price = $( '#price span' );
const $price_gross = $( '#price_gross span' );
const $price_gross_org = $( '#price_gross_org span' );
let price_gross = 0;
const $m2 = $( '#m2 span' );
const $m3 = $( '#m3 span' );
const $m2_all = $( '#m2_all span' );
const $m3_all = $( '#m3_all span' );
const $space = $( '#space span' );
const $fake_quantity = $( 'input[name="fake-quantity"]' );
$( 'table.variations' ).on( 'change', function(){
setTimeout( adjustQuantityOnProductPage, 1 );
});
$( '.variations_form' ).on( 'show_variation', function(){
fillVariantData();
});
$( document ).ready( function(){
$fake_quantity.on( 'change', function(){
adjustQuantityOnProductPage();
fillVariantData();
});
setTimeout( function(){
adjustQuantityOnProductPage();
bindEvents();
}, 200 );
});
function fillVariantData(){
if( !$( 'body' ).hasClass( 'single-product' ) ){
return;
}
let shipping_price = 0;
let selected = $( 'input[name="variation_id"]' ).val();
if( selected == undefined ){
selected = $( 'button[name="add-to-cart"]' ).val();
}
if( selected.length < 1 || selected == "0" ){
$price.html( '--' );
$price_gross.html( '--' );
$price_gross_org.html( '--' );
$m2.html( '--' );
$m3.html( '--' );
$space.html( '--' );
return;
}
let fqv = c2d( $quantity.val() ) / c2d( variants[ selected ].m2 );
fqv = fqv.toFixed();
if( $( 'body' ).hasClass( 'woocommerce-cart' ) ) $fake_quantity.val( fqv ); // tylko w koszyku
shipping_price = getCurrentShippingPrice( fqv );
let price = parseFloat( shipping_price ) * fqv / parseFloat( $quantity.val() ) + parseFloat( variants[ selected ].price );
console.log(parseFloat( variants[ selected ].price ));
let price_org = parseFloat( variants[ selected ].price );
// let price = parseFloat( shipping_price ) * fqv / parseFloat( $quantity.val() ) + parseFloat( variants[ selected ].price );
let space = variants[ selected ].space * fqv;
space = space.toFixed( 1 );
let m2_all = c2d( variants[ selected ].m2 ) * fqv;
m2_all = m2_all.toFixed( 2 );
// let m3_all = parseFloat(variants[ selected ].space.replace(/,/, '.'))*parseFloat(variants[ selected ].m2.replace(/,/, '.'))/10*fqv;
let m3_all = parseFloat(variants[ selected ].space.replace(/,/, '.'))*parseFloat(variants[ selected ].m2.replace(/,/, '.'));
m3_all = m3_all.toFixed( 2 );
// console.log(fqv + " fqv");
$price.html( price_without_tax( price ) );
price_gross = price.toFixed( 2 );
$price_gross.html( wc_price( price ) );
$price_gross_org.html(wc_price( price_org ));
$m2.html( variants[ selected ].m2 );
$m3.html(parseFloat(variants[ selected ].space.replace(/,/, '.')));
// $m3.html(variants[ selected ].space);
$space.html( space );
$m2_all.html( m2_all );
$m3_all.html( parseFloat(variants[ selected ].space.replace(/,/, '.'))*fqv );
// adjustQuantityOnProductPage();
}
function adjustQuantityOnProductPage(){
var m2_on_box = $("#variant-data #m2 span").text();
var m2_on_box_dot = m2_on_box.replace(',', '.');
var input_value_count = $('input[name="fake-quantity"]').val();
$('#m2_all span').text((m2_on_box_dot * input_value_count).toFixed(2));
if( !$( 'body' ).hasClass( 'single-product' ) ) return;
let selected = $( 'input[name="variation_id"]' ).val();
if( selected == undefined ) selected = Object.keys(variants)[0];
if( variants[ selected ] == undefined ){
$( '.total' ).html( '' );
return;
}
if ( isNaN( $fake_quantity.val() ) ) $fake_quantity.val( 1 );
$fake_quantity.val( parseInt( $fake_quantity.val() ) );
$quantity.attr( 'step', c2d( variants[ selected ].m2 ) );
$quantity.attr( 'min', c2d( variants[ selected ].m2 ) );
$quantity.val( c2d( variants[ selected ].m2 ) * $fake_quantity.val() );
let adjusted_quantity = c2d( variants[ selected ].m2 ) * $fake_quantity.val();
$quantity.val( adjusted_quantity );
let shipping_price = getCurrentShippingPrice( $fake_quantity.val() ) * parseInt( $fake_quantity.val() );
// console.log( ';ixcxc ');
// $space.html( 'xxx' );
// console.log( $space ) ;
setTimeout(function () {
let total = wc_price( price_gross * parseFloat( $quantity.val() ) );
$( '.total' ).html( total );
}, 100);
fillVariantData();
}
function adjustQuantityInCart( $btn ){
let $fake_quantity = $btn.parents( '.quantity' ).find( 'input[name="fake-quantity"]' );
let $quantity = $btn.parents( '.quantity' ).find( 'input.qty' );
let step = $quantity.attr( 'step' );
let adjusted_quantity = $fake_quantity.val() * step;
$quantity.val( adjusted_quantity ).trigger( 'change' );
}
function getCurrentShippingPrice( quantity ){
for( let i = 0; i <= shipping.length - 1; i++ ){
if( quantity >= shipping[i].od && quantity <= shipping[i].do ){
return shipping[i].cena;
break;
}
}
// return 5;
return 0;
}
$( document.body ).on( 'updated_cart_totals', bindEvents );
function bindEvents(){
$( '.woocommerce-cart input[name="fake-quantity"' ).on( 'change', function( e ){
adjustQuantityInCart( $( this ) );
});
$('.button_q').on('click', function () {
let $fq = $( this ).parents( '.quantity' ).find( 'input[name="fake-quantity"]' );
var $button = $(this);
var oldValue = $fq.val();
if ($button.text() == "+") {
var newVal = parseFloat(oldValue) + 1;
} else {
// Don't allow decrementing below zero
if (oldValue > 1) {
var newVal = parseFloat(oldValue) - 1;
} else {
newVal = 1;
}
}
$fq.val( newVal );
if( $( 'body' ).hasClass( 'single-product' ) ){
adjustQuantityOnProductPage( );
fillVariantData();
} else {
adjustQuantityInCart( $( this ) );
}
});
}
$( document.body ).on( 'updated_cart_totals', updateCartCounter );
function updateCartCounter(){
let total = 0;
$( 'input[name="fake-quantity"]' ).each( function(){
total += parseInt( $( this ).val() );
});
$( '.cart_in_header .count_cart' ).html( total );
// console.log( $( '.woocommerce-cart-form' ));
}
///show cf7 hurt in product
$('.prod_hurt .product_button_hurt').on('click tap', function(){
$(this).hide();
$('.prod_hurt .hurt_cf7').slideDown();
var this_prod_title = $('.product .summary h1.product_title').text();
$('.wpcf7-text.prod_title').val(this_prod_title);
$('.wpcf7-text.prod_title').attr('disabled', 'disabled');
});
})(jQuery);
(function($){
$('.slider_home-slider').slick({
dots: false,
infinite: true,
autoplay: true,
prevArrow: "",
nextArrow: "",
autoplaySpeed: 6000,
slidesToScroll: 1,
slidesToShow: 1,
arrows: true,
swipeToSlide: true
});
$('.home-slider-wrapper .arrow_box .next').on("click", function () {
$('.slick-next').trigger('click');
});
$('.home-slider-wrapper .arrow_box .prev').on("click", function () {
$('.slick-prev').trigger('click');
});
$('.slider_home-slider').on('beforeChange', function (event, slick, currentSlide, nextSlide) {
$('.home-slider-wrapper .arrow_box .active_slide').text(nextSlide+1);
});
$('.partner-slider').slick({
dots: false,
infinite: true,
autoplay: true,
// prevArrow: "",
// nextArrow: "",
autoplaySpeed: 4000,
slidesToScroll: 1,
slidesToShow: 4,
arrows: false,
swipeToSlide: true,
responsive: [
{
breakpoint: 1300,
settings: {
slidesToShow: 3,
slidesToScroll: 1
}
},
{
breakpoint: 780,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
$('.testimonials_row').slick({
dots: false,
infinite: true,
autoplay: true,
autoplaySpeed: 4000,
slidesToScroll: 1,
slidesToShow: 2,
arrows: false,
swipeToSlide: true,
responsive: [
{
breakpoint: 1084,
settings: {
slidesToShow: 2,
}
},
{
breakpoint: 764,
settings: {
slidesToShow: 1,
}
},
]
});
$('.gallery_row').slick({
dots: false,
infinite: false,
autoplay: false,
autoplaySpeed: 4000,
slidesToScroll: 1,
slidesToShow: 4,
arrows: false,
swipeToSlide: true,
responsive: [
{
breakpoint: 1484,
settings: {
slidesToShow: 3,
}
},
{
breakpoint: 1084,
settings: {
slidesToShow: 2,
}
},
{
breakpoint: 464,
settings: {
slidesToShow: 1,
}
},
]
});
$('.slick_post').slick({
dots: false,
infinite: true,
autoplay: false,
autoplaySpeed: 4000,
slidesToScroll: 1,
slidesToShow: 3,
arrows: false,
swipeToSlide: true,
responsive: [
{
breakpoint: 980,
settings: {
slidesToShow: 2,
}
},
{
breakpoint: 500,
settings: {
slidesToShow: 1,
}
},
]
});
if ($(window).width() < 960) {
$('.slick_prod').slick({
dots: false,
infinite: true,
autoplay: false,
autoplaySpeed: 4000,
slidesToScroll: 1,
slidesToShow: 3,
arrows: false,
swipeToSlide: true,
responsive: [
{
breakpoint: 700,
settings: {
slidesToShow: 2,
}
},
{
breakpoint: 500,
settings: {
slidesToShow: 1,
}
},
]
});
}
$('.contact_to_but').on('click', function(){
var this_prod_title1 = $('.product .summary h1.product_title').text(); $('.cf_product .wpcf7-text.prod_title').val(this_prod_title1); $('.cf_product .wpcf7-text.prod_title').attr('disabled', 'disabled');
$('html, body').animate({
scrollTop: $('#purch_box').offset().top - 230
}, 500, 'linear');
});
$(".variations_form").on("show_variation", function(event, variation) {
// setTimeout(function(){
console.log("wiara2");
const variationID = $('input[name=variation_id].variation_id').val();
const variationData = $('form.variations_form').data("product_variations");
console.log(variationID);
$(variationData).each(function(index,variation){
if ( variationID == variation.variation_id ) {
if ( variation.availability_html.indexOf('available-on-backorder') > -1 ) {
$('.buy_desk').remove();
$('.woocommerce.npwpMessage').remove();
$('form.variations_form button[type=submit]').hide();
$('.woocommerce-variation-description').before('Produkt dostępny na zamówienie Skontaktuj się w sprawie zakupu
');
$('.woocommerce-tabs').after('Produkt dostępny na zamówienie.
Zadzwoń bądź napisz!
');
$('.cf_product.hidecf').show();
$('.contact_to_but').on('click', function(){
var this_prod_title1 = $('.product .summary h1.product_title').text();
$('.cf_product .wpcf7-text.prod_title').val(this_prod_title1);
$('.cf_product .wpcf7-text.prod_title').attr('disabled', 'disabled');
$('html, body').animate({
scrollTop: $('#purch_box').offset().top - 230
}, 500, 'linear');
});
} else {
$('form.variations_form button[type=submit]').show();
$('.buy_desk').remove();
}
}
});
// },3500);
});
$( ".variations_form" ).on( "woocommerce_variation_select_change", function () {
setTimeout(function(){
$('input[name=variation_id].variation_id').change(function(){
const variationID = $(this).val();
const variationData = $('form.variations_form').data("product_variations");
$(variationData).each(function(index,variation){
if ( variationID == variation.variation_id ) {
if ( variation.availability_html.indexOf('available-on-backorder') > -1 ) {
$('.buy_desk').remove();
$('.woocommerce.npwpMessage').remove();
$('form.variations_form button[type=submit]').hide();
$('.woocommerce-variation-description').before('Produkt dostępny na zamówienie Skontaktuj się w sprawie zakupu
');
$('.woocommerce-tabs').after('Produkt dostępny na zamówienie.
Zadzwoń bądź napisz!
');
$('.cf_product.hidecf').show();
$('.contact_to_but').on('click', function(){
var this_prod_title1 = $('.product .summary h1.product_title').text();
$('.cf_product .wpcf7-text.prod_title').val(this_prod_title1);
$('.cf_product .wpcf7-text.prod_title').attr('disabled', 'disabled');
$('html, body').animate({
scrollTop: $('#purch_box').offset().top - 230
}, 500, 'linear');
});
} else {
$('form.variations_form button[type=submit]').show();
$('.buy_desk').remove();
}
}
});
});
}, 300);
});
function setup_collapsible_submenus() {
var $menu = $('header .et_mobile_menu'),
top_level_link = 'header .et_mobile_menu .menu-item-has-children > a';
$menu.find('a').each(function() {
$(this).off('click');
if ( $(this).is(top_level_link) ) {
// $(this).attr('href', '#');
}
if ( ! $(this).siblings('.sub-menu').length ) {
$(this).on('click', function(event) {
$(this).parents('.mobile_nav').trigger('click');
console.log("elo1");
});
} else {
$(this).on('click', function(event) {
console.log($(this));
if (!$(this).parent().hasClass('menu-item-2514')){
event.preventDefault();
}
$(this).parent().toggleClass('visible');
});
}
});
}
$(window).load(function() {
setTimeout(function() {
setup_collapsible_submenus();
}, 700);
});
})( jQuery );