// ACTIVITY INDICATOR
var imageLightBoxItems = {
count: 0,
byIndex: {},
byHref: {},
};
var activityIndicatorOn = function(){ $('
').appendTo('body'); },
activityIndicatorOff = function(){ $('#imagelightbox-loading').remove(); },
// OVERLAY
overlayOn = function(){ $('').appendTo('body'); },
overlayOff = function(){ $('#imagelightbox-overlay').remove(); },
// CLOSE BUTTON
closeButtonOn = function(instance){ $('').appendTo('body').on('click touchend', function() { $(this).remove(); instance.quitImageLightbox(); return false; }); },
closeButtonOff = function(){ $('#imagelightbox-close').remove(); },
// CAPTION
captionOn = function(){ var description = $('a[href="' + $('#imagelightbox').attr('src') + '"] img').attr('alt'); if (description != '' && description != undefined) $('' + description + '
').appendTo('body'); },
captionOff = function(){ $('#imagelightbox-caption').remove(); },
// NAVIGATION
navigationOn = function(instance, selector){ var images = $(selector); if (images.length) { var nav = $(''); for (var i = 0; i < images.length; i++) nav.append(''); nav.appendTo('body'); nav.on('click touchend', function() { return false; }); var navItems = nav.find('button'); navItems.on('click touchend', function() { var $this = $(this); if (images.eq($this.index()).attr('href') != $('#imagelightbox').attr('src')) instance.switchImageLightbox($this.index()); navItems.removeClass('active'); navItems.eq($this.index()).addClass('active'); return false; }) .on('touchend', function() { return false; }); } },
navigationUpdate = function(selector) { var items = $('#imagelightbox-nav button'); items.removeClass('active'); items.eq($(selector).filter('[href="' + $('#imagelightbox').attr('src') + '"]').index(selector)).addClass('active'); },
navigationOff = function(){ $('#imagelightbox-nav').remove(); },
// ARROWS
arrowsOn = function (instance, selector) { var $arrows = $(''); $arrows.appendTo('body'); $arrows.on('click touchend', function (e) { var $this = $(this); var index = imageLightBoxItems.byHref[$('#imagelightbox').attr('src')]; e.preventDefault(); if (typeof index === 'undefined') { return false; } if ($this.hasClass('imagelightbox-arrow-left')) { index = index - 1; if (typeof imageLightBoxItems.byIndex[index] === 'undefined') { index = imageLightBoxItems.count - 1; } } else { index = index + 1; if (typeof imageLightBoxItems.byIndex[index] === 'undefined') { index = 0; } } instance.switchImageLightbox(index); return false; }); },
arrowsOff = function() { $('.imagelightbox-arrow').remove(); };
var imageLighBoxSelector = 'a.fancybox',
imageLightboxInstance = $(imageLighBoxSelector).imageLightbox({
onStart: function() { overlayOn(); closeButtonOn( imageLightboxInstance ); arrowsOn( imageLightboxInstance, imageLighBoxSelector ); },
onEnd: function() { overlayOff(); captionOff(); closeButtonOff(); arrowsOff(); activityIndicatorOff(); },
onLoadStart: function() { captionOff(); activityIndicatorOn(); },
onLoadEnd: function() { captionOn(); activityIndicatorOff(); $( '.imagelightbox-arrow' ).css( 'display', 'block' ); }
});
$(imageLighBoxSelector).each(function (index) {
imageLightBoxItems.byHref[$(this).attr('href')] = index;
imageLightBoxItems.byIndex[index] = $(this).attr('href');
imageLightBoxItems.count += 1;
});
$(document).ready(function(){
$('#contactFormSend').on('submit', function(evt){
evt.preventDefault();
var k = [ 'name', 'question' ],
good = true;
$(this).find('[name]').removeClass('error');
$(this).find('p.ajaxInfo').hide();
if ( /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test( $(this).find('[name="mail"]').val() ) == false ){
$(this).find('[name="mail"]').addClass('error');
good = false;
}
if ( $(this).find('[name="phone"]').val().replace(/[^\d]/, '').length < 9 ){
$(this).find('[name="phone"]').addClass('error');
good = false;
}
for ( var i = 0; i < k.length; i++ ){
var obj = $(this).find('[name="'+ k[i] +'"]');
if ( obj.val().length <= 1 ){
good = false;
obj.addClass('error');
}
}
if ( good ){
$.post( $(this).attr('action'), $(this).serialize(), (function(response){
if (response.indexOf('false') === -1) {
$(this).find('input, textarea').val('');
$(this).find('p.ajaxInfo.ok').show();
} else {
$(this).find('p.ajaxInfo.error_send').show();
}
}).bind(this));
} else {
$(this).find('p.ajaxInfo.error').show();
}
});
// Zabiegaj linkom #
$('a[href=#]').click(function(e){
e.preventDefault();
});
});
$(window).load(function(){
$('.shop-category-carousel').owlCarousel({
lazyLoad : true,
navigation : true,
autoPlay: 3000
});
});
$(function () {
var $form = $('#form');
var $input = $form.find('input');
var start_url = $form.attr('action');
$form.on('change', function () {
var val = $input.val();
$form.attr('action', start_url + val);
console.log(start_url + val);
});
});
$("#show-tags").click(function(){
$(this).hide();
$(".tags-hidden").addClass("show");
});