');
var container = $('.productinfo .picture');
var basketForm = $('#productBasketForm');
$.each(container.parent().find('> .gallery .fancybox'), function (i) {
console.log(i);
var src = $(this).find('img').attr('src');
var item = $('
');
item.on('click', function () {
$('.productinfo .picture .gallery').owlCarousel().trigger('to.owl.carousel', [i]);
});
gallery.append(item);
});
basketForm.after(gallery);
});
if( $('.productinfo .picture .gallery > a').length > 1)
{
$('.productinfo .picture .gallery').owlCarousel({
autoplay: false,
items: 1,
nav: true,
navText: ['\u2039', '\u203A'],
loop : true
});
}
});
$(document).on('click', '.mobile-nav-toggle', function(evt){
evt.preventDefault();
evt.stopPropagation();
$('.mobile-nav nav').toggleClass('show');
});
$(document).on('click', '.shop-item', function(evt){
evt.preventDefault();
location.href = $(this).find('> a').attr('href');
});
$(document).on('click', '.shop-item form button', function(evt){
evt.stopPropagation();
// location.href = $(this).find('> a').attr('href');
});
$(document).on('click', '.category-nav a', function(evt){
evt.preventDefault();
$('.category-nav a').removeClass('active');
$(this).addClass('active');
$(this).closest('.container').find('.tab').removeClass('active');
$(this).closest('.container').find('.tab[data-type="'+ $(this).data('type') +'"]').addClass('active');
});
/*
* FORMULARZ REJESTRACJI
*/
$(document).on('change', '#r_addressData', function(evt){
if ( $(this).prop('checked') ){
// pokazujemy adres w formularzu
$('.address-switch').show(250);
} else {
// ukrywamy adres w formularzu
$('.address-switch').hide(250);
}
});
$('#registerFrm').on('submit', function(evt){
var good = true,
form = $(this),
fieldNames = [ 'name','surname','street','town','company' ];
form.find('[name]').removeClass('error');
form.find('p.ajaxInfo').hide();
// wymagane
if ( /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test( form.find('[name="email"]').val() ) == false ){
good = false;
form.find('[name="email"]').addClass('error');
}
if ( form.find('[name="pass"]').val().length < 6 || form.find('[name="pass"]').val() !== form.find('[name="pass2"]').val() ){
good = false;
form.find('[name="pass"], [name="pass2"]').addClass('error');
}
if ( form.find('[name="regulamin"]').prop('checked') === false ){
good = false;
form.find('[name="regulamin"]').addClass('error');
}
if ( form.find('[name="zgoda"]').prop('checked') === false ){
good = false;
form.find('[name="zgoda"]').addClass('error');
}
// opcjonalne
if ( form.find('[name="addressData"]').prop('checked') === true ){
if ( form.find('[name="phone"]').val().length > 0 && form.find('[name="phone"]').val().replace(/[^\d+]/gi, '').length < 9 ){
good = false;
form.find('[name="phone"]').addClass('error');
}
if ( form.find('[name="zipCode"]').val().length > 0 && /^[\d]{2}-[\d]{3}$/.test( form.find('[name="zipCode"]').val() ) === false ){
good = false;
form.find('[name="zipCode"]').addClass('error');
}
if ( form.find('[name="nip"]').val().length > 0 && !validatenip( form.find('[name="nip"]').val() ) ){
good = false;
form.find('[name="nip"]').addClass('error');
}
}
if ( !good ){
evt.preventDefault();
return false;
}
});
$('#registerFrmEdit').on('submit', function(evt){
var good = true,
form = $(this),
fieldNames = [ 'name','surname','street','town','company' ];
form.find('[name]').removeClass('error');
form.find('p.ajaxInfo').hide();
// wymagane
if ( /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test( form.find('[name="email"]').val() ) == false ){
good = false;
form.find('[name="email"]').addClass('error');
}
if ( form.find('[name="pass"]').val().length > 0 && form.find('[name="pass"]').val().length < 6 || form.find('[name="pass"]').val() !== form.find('[name="pass2"]').val() ){
good = false;
form.find('[name="pass"], [name="pass2"]').addClass('error');
}
if ( form.find('[name="regulamin"]').prop('checked') === false ){
good = false;
form.find('[name="regulamin"]').addClass('error');
}
if ( form.find('[name="zgoda"]').prop('checked') === false ){
good = false;
form.find('[name="zgoda"]').addClass('error');
}
// opcjonalne
if ( form.find('[name="phone"]').val().length > 0 && form.find('[name="phone"]').val().replace(/[^\d+]/gi, '').length < 9 ){
good = false;
form.find('[name="phone"]').addClass('error');
}
if ( form.find('[name="zipCode"]').val().length > 0 && /^[\d]{2}-[\d]{3}$/.test( form.find('[name="zipCode"]').val() ) === false ){
good = false;
form.find('[name="zipCode"]').addClass('error');
}
if ( form.find('[name="nip"]').val().length > 0 && !validatenip( form.find('[name="nip"]').val() ) ){
good = false;
form.find('[name="nip"]').addClass('error');
}
if ( !good ){
evt.preventDefault();
return false;
}
});
/*
* /FORMULARZ REJESTRACJI
*/
/*
* FORMULARZ KOSZYKA
*/
$('#productBasketForm').on('submit', function(evt){
if ( $(this).find('select[name="size"]').val() === "0" || $(this).find('select[name="size"]').val() === 0 ){
evt.preventDefault();
alert('Wybierz rozmiar');
return false;
}
});
/*
* /FORMULARZ KOSZYKA
*/
/*
* FORMULARZ ZAMÓWIENIA
*/
$('#zamowienieForm input[name="shipment"]').on('change', function(evt){
var shipmentPrice = parseFloat($(this).attr('rel')),
orderWorth = parseFloat($('.orderWorth').val()),
ow = (orderWorth + parseFloat(shipmentPrice));
$('#shippingRow .shippingPrice').text( shipmentPrice.toFixed(2).toString().replace('.', ',') +' zł');
if (+$(this).val() === 130) {
$('#zgoda-eraty-switch').removeClass('hidden');
} else {
$('#zgoda-eraty-switch').addClass('hidden');
}
$('.cena_sum').text( ow.toFixed(2).toString().replace('.', ',') +' zł' );
});
$(document).ready(function(){
$('#zamowienieForm input[name="shipment"]:checked').trigger('change');
});
$('#zamowienieForm').on('submit', function(evt){
var good = true,
form = $(this),
fieldNames = [ 'name','surname','street','town' ];
form.find('[name]').removeClass('error');
form.find('p.ajaxInfo').hide();
if ( /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test( form.find('[name="email"]').val() ) == false ){
good = false;
form.find('[name="email"]').addClass('error');
}
if ( form.find('[name="regulamin"]').prop('checked') === false ){
good = false;
form.find('[name="regulamin"]').addClass('error');
}
if ( form.find('[name="zgoda1"]').prop('checked') === false ){
good = false;
form.find('[name="zgoda1"]').addClass('error');
}
if (+form.find('[name="shipment"]:checked').val() === 130) {
if (form.find('[name="zgoda-eraty"]').prop('checked') === false) {
good = false;
form.find('[name="zgoda-eraty"]').addClass('error');
}
}
if ( form.find('[name="phone"]').val().replace(/[^\d+]/gi, '').length < 9 ){
good = false;
form.find('[name="phone"]').addClass('error');
}
if ( /^[\d]{2}-[\d]{3}$/.test( form.find('[name="zipCode"]').val() ) === false ){
good = false;
form.find('[name="zipCode"]').addClass('error');
}
var isNIP = false, isComp = false;
var goodNIP = true, goodComp = true;
if ( form.find('[name="company"]').val().length > 0 ){
isComp = true;
} else {
goodComp = false;
}
if ( form.find('[name="nip"]').val().length > 0 ){
isNIP = true;
if ( !validatenip( form.find('[name="nip"]').val() ) ){
goodNIP = false;
}
}
if ( isComp || isNIP ){
if ( !goodNIP ){
good = false;
form.find('[name="nip"]').addClass('error');
}
if ( !goodComp ){
good = false;
form.find('[name="company"]').addClass('error');
}
}
for ( var i = 0; i < fieldNames.length; i++ ){
var obj = form.find('[name="'+ fieldNames[i] +'"]');
if ( obj.val().length <= 1 ){
good = false;
obj.addClass('error');
}
}
if ( good === false ){
evt.preventDefault();
return false;
}
});
/*
* FORMULARZ ZAMÓWIENIA
*/
/*
* RABAT
*/
$(document).on('click', '.discount-box a.btn', function(evt){
var data = {
code : $('.discount-box input[name="discount_code"]').val(),
order_value : $('.discount-box input[name="order_value"]').val()
};
evt.preventDefault();
$.post(__URL__ + 'ajax/checkRabat.php', data, function(resp){
var value = 0,
value_type = '%',
order_value = parseFloat( $('.discount-box input[name="order_value"]').val() ),
end_value = order_value + 0;
$('#submitKoszykForm .totalPrice').text( order_value.toFixed(2).toString().replace('.', ',') + ' zł' );
$('.basket-table tbody .discountRow').remove();
if ( resp.hasOwnProperty('error') ){
alert(resp.error, 'danger');
} else if ( resp.hasOwnProperty('value') && resp.hasOwnProperty('value_type') ){
value = parseFloat(resp.value);
value_type = resp.value_type;
if ( value_type === '%' ){
end_value = order_value * (1-(value / 100));
} else { // if ( value_type === 'pln' ){
end_value = order_value - value;
}
if (end_value < 0) {
end_value = 0;
}
$('.basket-table tbody tr:last-of-type').before('
| Rabat | -'+ value.toString().replace('.', ',') + value_type.replace('pln', ' zł') +' | |
');
}
$('#submitKoszykForm .totalPrice').text( end_value.toFixed(2).toString().replace('.', ',') + ' zł' );
}, 'json');
});
$(document).ready(function(){
if ( $('.discount-box input[name="discount_code"]').length > 0 && $('.discount-box input[name="discount_code"]').val().length > 1 ){
$('.discount-box a.btn').trigger('click');
}
});
/*
* /RABAT
*/
$('#quick-contact-form').submit(function(evt) {
evt.preventDefault();
console.log('submited');
});
if (window.history.length === 1) {
$('#back-in-history').removeClass('show');
} else {
$('#back-in-history').addClass('show');
$('#back-in-history').on('click', function () {
window.history.back();
});
}
$('.fancyboxOnClick').on('click', function (evt) {
evt.preventDefault();
$(this).closest('.picture').next('.gallery').next('.gallery').find('.fancybox[href="'+ $(this).attr('href') +'"]').trigger('click');
});
$( '.readmoreContent' ).readmore({
speed: 75,
lessLink: '',
moreLink: '
Czytaj więcej',
collapsedHeight: 310
});
$('.switch-tab').click(function(){
$('#start-search-box').addClass("active");
$('.switch-tab').removeClass("active");
$(this).addClass("active");
$(this).parent().addClass("active");
});
var startSearch = $('#start-search-box');
if (startSearch.length > 0) {
var volumeMin = 0;
var volumeMax = 0;
var homeTypes = startSearch.find('.homeImg--content');
var homeTabItems = startSearch.find('.tab--item');
var ss_next = startSearch.find('.next');
var ss_prev = startSearch.find('.prev');
ss_next.click(function(){
var closesttForm = $(this).closest('form');
var tabItem = $(this).closest('.tab--item');
var tabIndex = tabItem.index();
closesttForm.find('.tab--item').removeClass('active');
tabItem.next().addClass('active');
});
ss_prev.click(function(){
var closesttForm = $(this).closest('form');
var tabItem = $(this).closest('.tab--item');
var tabIndex = tabItem.index();
closesttForm.find('.tab--item').removeClass('active');
tabItem.prev().addClass('active');
});
homeTypes.click(function(){
var closesttForm = $(this).closest('form');
var text = $(this).find('p').text();
var houseName = closesttForm.find('.houseName');
houseName.text(text);
volumeMin = $(this).attr('data-volume-min');
volumeMax = $(this).attr('data-volume-max');
console.log(volumeMin);
closesttForm.find('.minLimit').val(volumeMin);
closesttForm.find('.maxLimit').val(volumeMax);
homeTypes.removeClass('active');
$(this).addClass('active');
});
}
if (typeof homeSearchArray !== 'undefined') {
$(function () {
$('#param_3_min').val(200);
$('#config-box button.button').trigger('click');
})
}
$(function () {
$('[data-toggle="tooltip"]').tooltip({html:true})
})