(function(window, undefined){ window.jQuery(function($){ if($('html').hasClass('in-store')) { return; } // contact - form (function(){ var $form = $('#contact-form'); var $message = $('#contact-form-message'); var text = { success: { title: '', messages: { success: '' } }, error: { title: '', messages: { failure: '', invalid: '', wrong_captcha: '', empty: '', spam_ip: '', spam_link_name: '', spam_link_subject: '', spam_link_message: '', ext_data_consentment: '', refresh: '' } } }; $form.submit(function(e){ e.preventDefault(); $.ajax({ url: '/contact.php', type: 'POST', traditional: true, data: $form.serialize(), success: function(data){ var response = jQuery.parseJSON(data); var type = response.success ? 'success' : 'error'; var html = '

' + text[type].title + '

'; if(response.success) { html += '

' + text[type].messages.success + '

'; } else { var messages = []; for(var i = 0, l = response.errors.length; i < l; i++) { var error = response.errors[i]; messages[messages.length] = text[type].messages[error.error + (error.type ? '_' + error.type + (error.field ? '_' + error.field : '') : '')]; } html += ''; } $message.html(html + '
'); if(response.new_captcha) { $('#captcha_question').html(response.new_captcha); } } }); }); })(); // contact - map (function(){ var $map = $('#map'); if(!$map.length) { console.log('map does not exist'); return; } var $googlemap = $('#googlemap'); var $section = $map.closest('.map'); var $button = $section.find('.map-button'); var ll = $map.data('ll').split(','); var options = { zoom: $map.data('zoom') || 16, center: [ll[0], ll[1]], gestureHandling: true, gestureHandlingOptions: { duration: 1000, delay: 0, text: { touch: '', scroll: '', scrollMac: '' } } }; var map = L.map($map[0], options); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); L.marker(options.center).addTo(map); setTimeout(function(){ map.invalidateSize(); }, 500); })(); // scroll to top - based on 0003 (function(){ var $scroll_to_top = $('.scrollToTop'); var $window = $(window); $window.scroll(function(){ var scrollTop = $window.scrollTop(); if(scrollTop >= $window.height()) { $scroll_to_top.fadeIn(); } else { $scroll_to_top.fadeOut(); } }); $scroll_to_top.click(function(){ $('html, body').animate({ scrollTop: 0 }, 1000); return false; }); })(); }); })(Function('return this')());