1; 2(function ($) { 3 ////console.log(ajax_vars); 4 'use strict'; 5 const AJAX_URL = ajax_vars.rest_url; 6 var theme = { 7 init: () => { 8 theme.mobileMenu() 9 theme.various() 10 theme.owlCarousel() 11 theme.mainSearch() 12 theme.lightGallery() 13 theme.consultingForm() 14 theme.beforeAfter() 15 theme.select2() 16 theme.contactForms() 17 theme.footerMobileMenu() 18 }, 19 lightGallery: () => { 20 lightGallery(document.getElementById('lightgallery'), { 21 speed: 500, 22 selector: 'a', 23 }) 24 var elements = document.getElementsByClassName('lightgallery'); 25 for (let item of elements) { 26 lightGallery( 27 item, { 28 share: false, 29 selector: 'a' 30 } 31 ) 32 } 33 34 }, 35 owlCarousel: () => { 36 //console.log('owlCarousel init'); 37 if ($('.owl-carousel').not('.not-global').length) { 38 var defaultOptions = { 39 loop: false, 40 nav: true, 41 navText: ['<i class="bi bi-chevron-left"></i>', '<i class="bi bi-chevron-right"></i>'], 42 autoplay: false, 43 dots: true, 44 margin: 10, 45 responsiveClass: true, 46 responsive: { 47 0: { 48 items: 2, 49 nav: false 50 }, 51 600: { 52 items: 3, 53 }, 54 1200: { 55 items: 4 56 } 57 } 58 } 59 $('.owl-carousel').not('.not-global').each(function (i, obj) { 60 let options = $(obj).attr('data-options')
61 let customOptions = defaultOptions 62 if (options) { 63 options = JSON.parse(options) 64 customOptions = { 65 ...defaultOptions, 66 ...options, 67 } 68 } 69 70 $(obj).owlCarousel(customOptions) 71 72 $(obj).on('translated.owl.carousel', function (event) { 73 setLast(event.currentTarget) 74 }) 75 setLast(obj) 76 }) 77 78 function setLast (target) { 79 $(target).find('.owl-item').removeClass('lastActiveItem') 80 let totalActive = $(target).find('.owl-item.active').length 81 $(target) 82 .find('.owl-item.active') 83 .each(function (index) { 84 if (index === totalActive - 1 && totalActive > 1) { 85 $(this).addClass('lastActiveItem') 86 } 87 }) 88 } 89 } 90 }, 91 various: () => { 92 ////console.log('various init'); 93 if ($('.scope-icon').length) { 94 $('.scope-icon').each(function (i, obj) { 95 const scope = $(obj).data('rel') 96 $(obj).on('mouseover', () => { 97 $('.scope-label[data-rel=' + scope + ']').css('color', '#222') 98 }) 99 $(obj).on('mouseout', () => { 100 $('.scope-label[data-rel=' + scope + ']').css('color', 'inherit') 101 }) 102 }) 103 } 104 // $(window).on('scroll resize', function () { 105 // let chat_btn_pos = jQuery('.chat-btn').offset().top 106 // let footer_pos = jQuery('#wrapper-footer').offset().top 107 // chat_btn_pos >= footer_pos ? 108 // jQuery('.chat-btn').addClass('inverted') : 109 // jQuery('.chat-btn').removeClass('inverted') 110 // }); 111 // $('.chat-link').on('click', function () { 112 // LH_chat() 113 // }); 114 // Smooth scroll; 115 $('a').on('click', function (event) { 116 if ( 117 this.hash !== "" && 118 !$('body').hasClass('search-results') 119 ) { 120 event.preventDefault(); 121 var hash = this.hash.substr(1); 122 var element = document.getElementById(hash); 123 var headerOffset = 100; 124 var elementPosition = element.offsetTop; 125 var offsetPosition = elementPosition - headerOffset; 126 window.scrollTo({ 127 top: offsetPosition, 128 behavior: "smooth" 129 }); 130 // window.location.hash = hash; 131 } 132 }); 133 // Scroll solutions page to bottom 134 if ( 135 $('body').hasClass('post-type-archive-solution') && 136 window.location.href.indexOf('_scope') > -1 137 ) { 138 setTimeout(() => { 139 $([document.documentElement, document.body]).animate({ 140 scrollTop: $("#main").offset().top - 100 141 }, 500); 142 }, 1000); 143 144 } 145 146 // Scroll Q&A tax page to question (open accordion); 147 if ( 148 $('body').hasClass('tax-qa_category') && 149 window.location.hash 150 ) { 151 const currentAccordion = $(window.location.hash); 152 setTimeout(() => { 153 window.scrollTo({ 154 top: $(currentAccordion).offset().top - 100, 155 behavior: 'smooth' 156 }); 157 currentAccordion.find('.accordion-collapse').addClass('show'); 158 }, 1000); 159 } 160 161 // Check courses availability; 162 $('.course-form-wrapper').each(function (i, obj) { 163 // Check if obj has attribute data-course-id; 164 if ( 165 $(obj).attr('data-max-places') 166 ) { 167 const maxPlaces = $(obj).attr('data-max-places'); 168 if (maxPlaces <= 0) { 169 $(obj).find('button').attr('disabled', 'disabled'); 170 $(obj).find('button').html('Prenotazione non disponibile'); 171 } 172 } 173 }); 174 175 $('.waterproof-toggler').on('click', function () { 176 $('body').toggleClass('waterproof-open'); 177 }); 178 }, 179 mainSearch: () => { 180 // Search form input toggler; 181 if ($('.search-button').length) { 182 $(document).on('click', '.search-button a', () => { 183 $('.search-bar').addClass('active') 184 $('.search-bar #s').focus() 185 }) 186 $(document).on('click', '.close-search-bar', () => { 187 $('.search-bar').removeClass('active') 188 }) 189 } 190 }, 191 consultingForm: () => { 192 if ($('#consulting-form').length) { 193 const $form = $('#consulting-form'); 194 const $submitBtn = $form.find('#submit'); 195 196 // Fix checkbox esclusivo pagina consulenza; 197 $form.find('.privacy input[type=checkbox]').click(function (e) { 198 let checkedState = e.target.checked; 199 $form.find('.privacy input[type=checkbox]').each(function () { 200 $(this).prop('checked', false); 201 });
202 $(this).prop('checked', checkedState); 203 }); 204 205 // Filtro caratteri speciali su input text 206 $form.find('input[type=text]').on('keypress', function (event) { 207 var regex = new RegExp("^[a-zA-Z0-9'à èòùìé, -]+$"); 208 var key = String.fromCharCode(!event.charCode ? event.which : event.charCode); 209 if (!regex.test(key)) { 210 event.preventDefault(); 211 return false; 212 } 213 }); 214 215 // Invio form pagina consulenza; 216 $form.on('submit', (e) => { 217 e.preventDefault(); 218 if (!$form.valid()) { 219 Swal.fire( 220 'Ooops!', 221 'Uno o più campi hanno degli errori. Controlla e riprova.', 222 'warning' 223 ); 224 return false; 225 } 226 227 $submitBtn.prop('disabled', true); 228 $.ajax({ 229 type: 'POST', 230 url: `${AJAX_URL}v1/submitForm`, 231 data: $form.serialize(), 232 dataType: 'json', 233 encode: true, 234 }).done(function (data) { 235 document.getElementById("consulting-form").reset(); 236 if (parseInt(data.result, 10) === 200) { 237 Swal.fire( 238 'Grazie per averci scritto!', 239 'Verrai contattato al più presto da un nostro incaricato.', 240 'success' 241 ) 242 } else { 243 Swal.fire( 244 'Ooops!', 245 'Si è verificato un problema. Prego riprova.', 246 'warning' 247 ) 248 } 249 }).fail(function (jqXHR, textStatus, errorThrown) { 250 console.error('consulting-form submit failed', { 251 status: jqXHR.status, 252 textStatus, 253 errorThrown, 254 responseText: jqXHR.responseText, 255 }); 256 Swal.fire( 257 'Ooops!', 258 'Risposta non valida dal server. Prego riprova.', 259 'warning' 260 ) 261 }).always(function () { 262 $submitBtn.prop('disabled', false); 263 }); 264 }); 265 } 266 }, 267 mobileMenu: () => { 268 $(document).ready(() => { 269 $('#mobilemenu li.menu-item-has-children') 270 .on('click', function (e) { 271 let $this = $(this); 272 if ($this.hasClass('open')) { 273 $this 274 .removeClass('open') 275 .children('.sub-menu') 276 .stop() 277 .slideUp(300) 278 } else { 279 $('#mobilemenu li.menu-item-has-children').removeClass('open') 280 $('.sub-menu').slideUp(300, function () { 281 $this 282 .addClass('open') 283 .children('.sub-menu') 284 .stop() 285 .slideDown(300) 286 }) 287 } 288 }) 289 document.addEventListener('swiped-left', function (e) { 290 document 291 .getElementsByTagName('html')[0] 292 .classList.remove('mobileMenuOpen') 293 }) 294 }) 295 }, 296 beforeAfter: () => { 297 if ($('#before-after').length) { 298 $.fn.BeerSlider = function (options) { 299 options = options || {}; 300 return this.each(function () { 301 new BeerSlider(this, options); 302 }); 303 }; 304 $('#before-after').BeerSlider({ 305 start: 50 306 }); 307 } 308 }, 309 contactForms: () => { 310 $('.wpcf7-form').on('submit', function () { 311 $(this).find('button').prop('disabled', true) 312 }) 313 document.addEventListener('wpcf7submit', (event) => { 314 $('.wpcf7-form').find('button').prop('disabled', false) 315 // console.log(event) 316 switch (event.detail.status) { 317 case 'validation_failed': 318 Swal.fire( 319 'Ooops!', 320 event.detail.apiResponse.message, 321 'warning' 322 ) 323 break 324 case 'mail_sent': 325 Swal.fire( 326 'Ben fatto!', 327 event.detail.apiResponse.message, 328 'success' 329 ) 330 break 331 } 332 }) 333 }, 334 select2: () => { 335 $('.advanced-select').select2({ 336 theme: 'bootstrap-5' 337 }); 338 }, 339 footerMobileMenu: () => { 340 $(document).ready(() => { 341 $('#wrapper-footer h3.widget-title').on('click', function () { 342 let $this = $(this); 343 let $next = $this.next('div'); 344 345 if ($next.hasClass('open')) { 346 $next.removeClass('open'); 347 } else { 348 $('#wrapper-footer h3.widget-title').next('div').removeClass('open'); 349 $next.addClass('open'); 350 } 351 }); 352 }); 353 } 354 } 355 theme.init(); 356})(jQuery); 357 358 359// On page ready (document ready); 360jQuery(document).ready(function ($) { 361 // Select all items with data-background-image attribute 362 // and set background image; 363 $('[data-background-image]').each(function (i, obj) { 364 const bgImage = $(obj).attr('data-background-image'); 365 $(obj).css('background-image', `url(${bgImage})`); 366 }); 367 368 $('.owl-carousel').each(function () { 369 //Find each set of dots in this carousel 370 $(this).find('.owl-dot').each(function (index) { 371 //Add one to index so it starts from 1 372 $(this).attr('aria-label', `owl-btn-${index + 1}`); 373 }); 374 }); 375 376 $('.owl-nav').each(function () { 377 //Find each set of dots in this carousel 378 // Rimuovi role="presentation" messo da OwlCarousel: è in conflitto con 379 // un <button>
379 (focusabile) e con aria-label, quindi non viene mai applicato. 380 $(this).find('.owl-prev').removeAttr('role').attr('aria-label', 'owl-btn-prev'); 381 $(this).find('.owl-next').removeAttr('role').attr('aria-label', 'owl-btn-next'); 382 }); 383});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.