// 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') + '"]').attr('data-desc'); 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
});
$('.upper-carousel').owlCarousel({
items: 1,
nav: false,
dots: false,
autoplay: true,
autoplaySpeed: 2000,
loop : true,
animateIn: "fadeIn",
animateOut: "fadeOut"
});
});
$('.slider').owlCarousel({
items: 1,
nav: false,
dots: false,
autoplay: true,
autoplaySpeed: 2000,
loop : true
});
$('.new-slider .carousel').owlCarousel({
items: 1,
responsive: {
0: {
items: 1
},
440: {
items: 2
},
1280: {
items: 3
}
},
nav: true,
navText: ['‹','›'],
dots: false,
autoplay: true,
loop: true,
autoplaySpeed: 1000,
autoplayTimeout: 3000
});
/*
$('.slider-buttons a').click(function(e){
if( !$(this).hasClass("alter") ) {
e.preventDefault();
$('.slider-oferta, .slider-gazetka').hide();
$( '.slider-' + $(this).data("target") ).show();
}
});
*/
var galleryShopItem = $('.gallery-shop .gallery .item').length;
var galleryShopLoop = true;
if (galleryShopItem <= 1) {
galleryShopLoop = false;
}
$('.gallery-shop .gallery').owlCarousel({
items: 1,
nav: true,
dots: false,
autoplay: false,
autoplaySpeed: 2000,
loop : galleryShopLoop,
navText: ['‹','›']
});
var galleryPartners = $('.partners-gallery .gallery .gallery-item').length;
var galleryPartnersLoop = true;
if (galleryPartners <= 1) {
galleryPartnersLoop = false;
}
$('.partners-gallery .gallery').owlCarousel({
items: 8,
nav: false,
dots: false,
autoplay: true,
autoplaySpeed: 700,
autoplayTimeout: 1000,
loop : galleryPartnersLoop,
navText: ['‹','›'],
responsive: {
0: {
items: 2
},
380: {
items: 3
},
540: {
items: 4
},
991: {
items: 8
}
}
});
var gMapCitySelector = function () {
var that = {
elements: {
city: $('#registerFrmEdit input[name="vr_city"]'),
address: $('#registerFrmEdit input[name="vr_address"]'),
output: $('#registerFrmEdit input[name="vr_map_coords"]')
}
};
var startingPoing = '52.17393169256849,19.2041015625';
var mapContainerId = 'gMapCitySelect';
var map;
var marker;
var initialize = function () {
bindInputElements();
initMap();
return that;
};
var bindInputElements = function () {
that.elements.city.on('change', inputElementsOnChange);
that.elements.address.on('change', inputElementsOnChange);
};
var inputElementsOnChange = function () {
var city = that.elements.city.val();
var address = that.elements.address.val();
var fullAddress = city + ' ' + address;
updateLatLngFromAddress(fullAddress);
};
var updateLatLngFromAddress = function (address) {
var geo = new google.maps.Geocoder();
var data = {address: address};
geo.geocode(data, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
marker.setPosition(results[0].geometry.location);
updateMapCenter(results[0].geometry.location);
updateMapCenterInput(results[0].geometry.location);
} else {
alert("Nie znaleziono!");
}
});
};
var initMap = function () {
var centerLatLng = getStartingLatLng();
var options = {
zoom: 12,
center: centerLatLng,
disableDefaultUI: false,
mapTypeControl: true,
scaleControl: true,
navigationControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: [ { "featureType": "administrative", "elementType": "labels.text.fill", "stylers": [ { "color": "#444444" } ] }, { "featureType": "landscape", "elementType": "all", "stylers": [ { "color": "#f2f2f2" } ] }, { "featureType": "poi", "elementType": "all", "stylers": [ { "visibility": "off" } ] }, { "featureType": "road", "elementType": "all", "stylers": [ { "saturation": -100 }, { "lightness": 45 } ] }, { "featureType": "road.highway", "elementType": "all", "stylers": [ { "visibility": "simplified" } ] }, { "featureType": "road.arterial", "elementType": "labels.icon", "stylers": [ { "visibility": "off" } ] }, { "featureType": "transit", "elementType": "all", "stylers": [ { "visibility": "off" } ] }, { "featureType": "water", "elementType": "all", "stylers": [ { "color": "#46bcec" }, { "visibility": "on" } ] }, { "featureType": "water", "elementType": "geometry.fill", "stylers": [ { "color": "#b5cf6a" } ] }, { "featureType": "water", "elementType": "geometry.stroke", "stylers": [ { "visibility": "off" }, { "hue": "#ff0000" } ] }, { "featureType": "water", "elementType": "labels.text.stroke", "stylers": [ { "visibility": "off" } ] } ]
};
map = new google.maps.Map(document.getElementById(mapContainerId), options);
google.maps.event.addListener(map, 'click', onMapClick);
addMarkerToMap(centerLatLng);
};
var getStartingLatLng = function () {
var latLng;
var userValue = that.elements.output.val().trim();
if (userValue.length > 3) {
latLng = userValue.split(',');
} else {
latLng = startingPoing.split(',');
}
return new google.maps.LatLng(latLng[0], latLng[1]);
};
var onMapClick = function (evt) {
ereaseMarker();
addMarkerToMap(evt.latLng);
};
var updateMapCenter = function (latLng) {
map.panTo(latLng);
};
var updateMapCenterInput = function (map_center) {
var center = map_center.lat() + ',' + map_center.lng();
that.elements.output.val(center);
};
var ereaseMarker = function () {
if (marker) {
marker.setMap(null);
}
};
var addMarkerToMap = function (location) {
var image = new google.maps.MarkerImage(__URL__ + 'admin/skins/default/marker.png',
new google.maps.Size(30, 47),
new google.maps.Point(0, 0),
new google.maps.Point(30, 47));
marker = new google.maps.Marker({
position: location,
map: map,
draggable: true,
title: 'przenieś ten marker w miejsce swojej pracowni',
icon: image
});
updateMapCenterInput(location);
google.maps.event.addListener(marker, 'dragend', function (evt) {
updateMapCenterInput(evt.latLng);
});
};
return initialize();
};
if ($('#gMapCitySelect').length === 1 && $('.page-rejestracja').length === 0) {
gMapCitySelector();
}
$('.one-gallery').click(function(e){
e.preventDefault();
var _id = $(this).attr("id");
$('.tab-gallery').removeClass("active");
var _nid = _id.replace("id-", "gallery-");
$('#' + _nid).addClass("active");
});
/*
$("#id-229").click(function(){
$(".tab-gallery").removeClass("active");
$("#gallery-229").toggleClass("active");
});
$("#id-230").click(function(){
$(".tab-gallery").removeClass("active");
$("#gallery-230").toggleClass("active");
});
*/
var gMapShops = function () {
var that = {
elements: {
name: $('#pins input[name="vr_map_name[]"]'),
output: $('#pins input[name="vr_map_coords[]"]')
}
};
var startingPoing = '49.89445,19.52288';
var mapContainerId = 'gMapShops';
var map;
var marker;
var initialize = function () {
initMap();
return that;
};
var updateLatLngFromAddress = function (address) {
var geo = new google.maps.Geocoder();
var data = {address: address};
geo.geocode(data, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
marker.setPosition(results[0].geometry.location);
updateMapCenter(results[0].geometry.location);
updateMapCenterInput(results[0].geometry.location);
} else {
alert("Nie znaleziono!");
}
});
};
var initMap = function () {
var centerLatLng = getStartingLatLng();
var options = {
zoom: 10,
center: centerLatLng,
disableDefaultUI: false,
mapTypeControl: true,
scaleControl: true,
navigationControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: [ { "featureType": "administrative", "elementType": "labels.text.fill", "stylers": [ { "color": "#444444" } ] }, { "featureType": "landscape", "elementType": "all", "stylers": [ { "color": "#f2f2f2" } ] }, { "featureType": "poi", "elementType": "all", "stylers": [ { "visibility": "off" } ] }, { "featureType": "road", "elementType": "all", "stylers": [ { "saturation": -100 }, { "lightness": 45 } ] }, { "featureType": "road.highway", "elementType": "all", "stylers": [ { "visibility": "simplified" } ] }, { "featureType": "road.arterial", "elementType": "labels.icon", "stylers": [ { "visibility": "off" } ] }, { "featureType": "transit", "elementType": "all", "stylers": [ { "visibility": "off" } ] }, { "featureType": "water", "elementType": "all", "stylers": [ { "color": "#46bcec" }, { "visibility": "on" } ] }, { "featureType": "water", "elementType": "geometry.fill", "stylers": [ { "color": "#b5cf6a" } ] }, { "featureType": "water", "elementType": "geometry.stroke", "stylers": [ { "visibility": "off" }, { "hue": "#ff0000" } ] }, { "featureType": "water", "elementType": "labels.text.stroke", "stylers": [ { "visibility": "off" } ] } ]
};
map = new google.maps.Map(document.getElementById(mapContainerId), options);
//google.maps.event.addListener(map, 'click', onMapClick);
var markerData = $("#pins input[name=coords]").val();
if( markerData.split("#").length > 1){
// Multiple
markersArr = markerData.split("#");
var count = markersArr.length;
for( a = 0; a < count; a++ ){
var spl = markersArr[a].split("::");
var ll = spl[0].split(",");
locPoint = new google.maps.LatLng(ll[0], ll[1]);
addMarkerToMap(locPoint, spl[1]);
}
} else {
// Single
addMarkerToMap(centerLatLng, name);
}
addMainMarker();
};
var getStartingLatLng = function () {
var latLng;
latLng = startingPoing.split(',');
return new google.maps.LatLng(latLng[0], latLng[1]);
};
var updateMapCenter = function (latLng) {
map.panTo(latLng);
};
var addMainMarker = function () {
var image = new google.maps.MarkerImage(__URL__ + 'admin/skins/default/markermain.png',
new google.maps.Size(30, 47),
new google.maps.Point(0, 0),
new google.maps.Point(30, 47));
_location = new google.maps.LatLng(49.853375,19.340249900000003);
_title = 'MSH Wizan - siedziba główna. Andrychów, ul.Legionów 7';
marker = new google.maps.Marker({
position: _location,
map: map,
draggable: false,
title: _title,
labelContent: _title,
labelInBackground: false,
icon: image
});
opis = _title;
var infowindow = new google.maps.InfoWindow({
content: 'MSH Wizan - siedziba główna
34-120 Andrychów, ul.Legionów 7
'
});
marker.addListener("mouseover", function() {
infowindow.open(map, this);
});
marker.addListener("mouseout", function() {
infowindow.close();
});
//updateMapCenterInput(location);
};
var addMarkerToMap = function (location, title) {
var image = new google.maps.MarkerImage(__URL__ + 'admin/skins/default/marker.png',
new google.maps.Size(30, 47),
new google.maps.Point(0, 0),
new google.maps.Point(30, 47));
marker = new google.maps.Marker({
position: location,
map: map,
draggable: false,
title: title,
labelContent: title,
labelInBackground: false,
icon: image
});
opis = title;
var infowindow = new google.maps.InfoWindow({
content: '' + opis + '
'
});
marker.addListener("mouseover", function() {
infowindow.open(map, this);
});
marker.addListener("mouseout", function() {
infowindow.close();
});
//updateMapCenterInput(location);
};
return initialize();
};
if ($('#gMapShops').length === 1) {
gMapShops();
}
var $resSections = $('.responsiveImg');
function mobileBackground(){
var width = $( document ).width();
$resSections.removeClass('mobileImg');
if( width < 500 ){
$resSections.each(function(){
var dataMobile = $(this).data('res-xs');
if( dataMobile.length > 5 ){
$(this).addClass('mobileImg')
.css( {'background-image':'url("' + dataMobile + '")'} );
}
});
}else{
$resSections.each(function(){
var dataMobile = $(this).data('res-st');
if( dataMobile.length > 5 ){
$(this).addClass('mobileImg')
.css( {'background-image':'url("' + dataMobile + '")'} );
}
});
}
}
var $resSectionsHeader = $('.slider-min');
function mobileBackgroundHeader(){
var width = $( document ).width();
$resSectionsHeader.removeClass('mobileImg');
if( width < 700 ){
$resSectionsHeader.each(function(){
var dataMobile = $(this).data('res-xs');
if( dataMobile.length > 5 ){
$(this).addClass('mobileImg')
.css( {'background-image':'url("' + dataMobile + '")'} );
}
});
}else{
$resSectionsHeader.each(function(){
var dataMobile = $(this).data('res-st');
if( dataMobile.length > 5 ){
$(this).addClass('mobileImg')
.css( {'background-image':'url("' + dataMobile + '")'} );
}
});
}
}
window.onresize = function(event) {
mobileBackground();
mobileBackgroundHeader();
};
mobileBackground();
mobileBackgroundHeader();
if($('.carousel-products').length >0){
$('.carousel-products').owlCarousel({
items: 4,
nav: true,
dots: false,
autoplay: false,
autoplaySpeed: 2000,
loop : true,
navText: ['‹','›'],
responsive: {
0 : {
items: 1
},
1000: {
items: 2
},
1200: {
items:3
},
1300: {
items:4
}
}
});
}