1jQuery(document).ready(function($){ 2 var $win = $(window); 3 4 $(window).on('scroll', $win, function() { 5 var $nav = $('.site-header'); 6 7 if($win.scrollTop() > 100) { 8 $nav.addClass('sticky'); 9 } else { 10 $nav.removeClass('sticky'); 11 } 12 }); 13 14 /* HERO SLIDER */ 15 if ($(".hero_slider_swiper")[0]){ 16 var swiper = new Swiper('.hero_slider_swiper', { 17 slidesPerView: '1', 18 spaceBetween: 0, 19 loop: true, 20 effect: 'fade', 21 fadeEffect: { 22 crossFade: true, 23 }, 24 autoplay: { 25 delay: 4000, 26 disableOnInteraction: false, 27 }, 28 speed: 1500, 29 pagination: { 30 el: ".swiper-hero-slider-pagination", 31 clickable: true, 32 type: 'bullets', 33 }, 34 }); 35 36 $(".hero_slider_swiper").find('.swiper-hero-slider-pagination-clone').each(function () { 37 let $paginationClone = $(".hero_slider_swiper").find('.swiper-hero-slider-pagination.root').clone(); 38 $(this).append($paginationClone.removeClass('root').show()); 39 40 $(this).on('click', '.swiper-pagination-bullet', function () { 41 let bulletIndex = Array.prototype.indexOf.call(this.parentNode.children, this); 42 swiper.slideToLoop(bulletIndex); 43 }); 44 45 swiper.on('paginationUpdate', function () { 46 $(".hero_slider_swiper").find('.swiper-hero-slider-pagination').each(function () { 47 let $pag = $(this); 48 $pag.find('.swiper-pagination-bullet') 49 .removeClass('swiper-pagination-bullet-active') 50 .eq(swiper.realIndex) 51 .addClass('swiper-pagination-bullet-active'); 52 }); 53 }); 54 }); 55 } 56 57 // Swiper - Ricette 58 if ($(".ricette_slider_swiper")[0]){ 59 var swiper = new Swiper('.ricette_slider_swiper', { 60 autoplay: { 61 delay: 5000, 62 disableOnInteraction: false, 63 pauseOnMouseEnter: true, 64 }, 65 loop: true, 66 slidesPerView: '3', 67 speed: 500, 68 centeredSlides: true, 69 spaceBetween: 10, 70 navigation: { 71 prevEl: '.ricette-swiper-nav.prev', 72 nextEl: '.ricette-swiper-nav.next', 73 }, 74 breakpoints: { 75 1200: { 76 //spaceBetween: -50, 77 }, 78 992: { 79 //spaceBetween: -40, 80 }, 81 768: { 82 slidesPerView: '3', 83 }, 84 0: { 85 slidesPerView: '1', 86 } 87 }, 88 }); 89 } 90 91 // Swiper - Edizioni 92 if ($(".edizioni_swiper")[0]){ 93 var swiper = new Swiper('.edizioni_swiper', { 94 autoplay: { 95 delay: 8000, 96 disableOnInteraction: false, 97 pauseOnMouseEnter: true, 98 }, 99 loop: false, 100 slidesPerView: '1', 101 speed: 500, 102 spaceBetween: 50, 103 navigation: { 104 prevEl: '.edizioni-swiper-nav.prev', 105 nextEl: '.edizioni-swiper-nav.next', 106 }, 107 }); 108 } 109 110 // Swiper - Tips 111 if ($(".tips_carousel_swiper")[0]){ 112 var swiper = new Swiper('.tips_carousel_swiper', { 113 autoplay: { 114 delay: 5000, 115 disableOnInteraction: false, 116 pauseOnMouseEnter: true, 117 }, 118 loop: false, 119 slidesPerView: '2', 120 speed: 500, 121 spaceBetween: 100, 122 navigation: { 123 prevEl: '.tipcarousel-swiper-nav.prev', 124 nextEl: '.tipcarousel-swiper-nav.next', 125 }, 126 pagination: { 127 el: ".swiper-tips-pagination", 128 clickable: true, 129 type: 'bullets', 130 }, 131 breakpoints: { 132 1200: { 133 //spaceBetween: -50, 134 }, 135 992: { 136 slidesPerView: '2', 137 }, 138 768: { 139 slidesPerView: '2', 140 spaceBetween: 50, 141 }, 142 0: { 143 slidesPerView: '1', 144 } 145 }, 146 }); 147 } 148 149 // Swiper - Percorsi 150 if ($(".percorsi_swiper")[0]){ 151 var swiper = new Swiper('.percorsi_swiper', { 152 autoplay: { 153 delay: 5000, 154 disableOnInteraction: false, 155 pauseOnMouseEnter: true, 156 }, 157 loop: true, 158 slidesPerView: '1', 159 speed: 500, 160 spaceBetween: 0, 161 pagination: { 162 el: ".swiper-percorsi-pagination", 163 clickable: true, 164 type: 'bullets', 165 }, 166 }); 167 } 168 169 170 // PRESS ROOM 171 if ($(".press-room_main")[0]){ 172 173 // MASONRY 174 var macy = Macy({ 175 container: '.press-room_main #pressmasonry', 176 trueOrder: false, 177 waitForImages: false, 178 margin: 10, 179 columns: 2, 180 breakAt: { 181 1200: 2, 182 940: 2, 183 520: 2, 184 400: 1 185 } 186 }); 187 188 // LIGHTBOX 189 var lightbox = function(){ 190 var src = $('.press-room_main .active img').attr('src'); 191 var href = $('.press-room_main .active a').attr('href'); 192 $('.press-room_main #lightbox .gallimg img').attr('src', src); 193 $('.press-room_main #lightbox .gallimg a').attr('href', href); 194 } 195 196 // Image is clicked 197 $('.press-room_main #pressmasonry div').click(function(){ 198 $('.press-room_main #lightbox').css('display','flex'); 199 $(this).addClass('active'); 200 lightbox(); 201 }); 202 203 // Close button clicked 204 $('.press-room_main .close').click(function(){ 205 $('.press-room_main div').removeClass('active'); 206 $('.press-room_main #lightbox').hide(); 207 }); 208 209 // Next button clicked 210 $('.press-room_main .next').click(function(){ 211 if( $('.press-room_main .active').parent('#pressmasonry').children('div:last').hasClass('active') ) { 212 $('.press-room_main .active').removeClass().parent('#pressmasonry').children('div:first').addClass('active'); 213 lightbox(); 214 } else { 215 $('.press-room_main .active').removeClass().next('div').addClass('active'); 216 lightbox(); 217 } 218 }); 219 220 // Prev button clicked 221 $('.press-room_main .prev').click(function(){ 222 if( $('.press-room_main .active').parent('#pressmasonry').children('div:first').hasClass('active') ) { 223 $('.press-room_main .active').removeClass().parent('#pressmasonry').children('div:last').addClass('active'); 224 lightbox(); 225 } else { 226 $('.press-room_main .active').removeClass().prev('div').addClass('active'); 227 lightbox(); 228 } 229 }); 230 } 231 232 233 234 if ($(".griglia_ricette")[0]){ 235 // Cache selectors 236 var $grid = $('.griglia_ricette'), 237 $module = $grid.find('.ricette-filtri'), 238 $results = $module.find('#recipes-results'), 239 $load = $('#load-more'); 240 241 // State 242 var currentTerm = 'all', 243 currentPage = 1; 244 245 // Common fetch function 246 function fetchRecipes(term, page, replace) { 247 $.ajax({ 248 url: RicettaAjax.ajax_url, 249 type: 'POST', 250 dataType: 'json', 251 data: { 252 action: 'filtri_ricetta', 253 term: term, 254 page: page, 255 nonce: RicettaAjax.nonce 256 }, 257 beforeSend: function(){ 258 if (replace) { 259 $results.html('<div class="loading">Loading...</div>'); 260 } else { 261 $load.text('Loading...').prop('disabled', true); 262 } 263 }, 264 success: function(res) { 265 if (!res.success) return; 266 267 // Insert or append 268 if (replace) { 269 $results.html(res.data.html); 270 } else { 271 // assume res.data.html always wraps <div.related_items>â¦</div> 272 var $tmp = $('<div>').append(res.data.html); 273 var newHtml = $tmp.find('.related_items').html(); 274 $results.find('.related_items').append(newHtml); 275 } 276 277 // Update Load More button 278 if (page < res.data.max_pages) { 279 $load 280 .show() 281 .text('Load More') 282 .prop('disabled', false) 283 .data('page', page); 284 } else { 285 $load.hide(); 286 } 287 }, 288 error: function() { 289 if (replace) { 290 $results.html('<p>Errore durante il caricamento.</p>'); 291 } else { 292 $load.text('Errore, riprova').prop('disabled', false); 293 } 294 } 295 }); 296 } 297 298 // Filter buttons 299 $module.on('click', '.filter-btn', function(){ 300 var $btn = $(this); 301 currentTerm = $btn.data('term'); 302 currentPage = 1; 303 304 // Toggle active 305 $module.find('.filter-btn').removeClass('active'); 306 $btn.addClass('active'); 307 308 // Fetch & replace 309 fetchRecipes(currentTerm, currentPage, true); 310 }); 311 312 // Load More button 313 $load.on('click', function(){ 314 var nextPage = ( $(this).data('page') || currentPage ) + 1; 315 currentPage = nextPage; 316 fetchRecipes(currentTerm, currentPage, false); 317 }); 318 } 319 320 if ($(".griglia_news")[0]){ 321 // Cache selectors 322 var $grid = $('.griglia_news'), 323 $module = $grid.find('.ricette-filtri'), 324 $results = $module.find('#recipes-results'), 325 $load = $('#load-more'); 326 327 // State 328 var currentTerm = 'all', 329 currentPage = 1; 330 331 // Common fetch function 332 function fetchRecipes(term, page, replace) { 333 $.ajax({ 334 url: NewsAjax.ajax_url, 335 type: 'POST', 336 dataType: 'json', 337 data: { 338 action: 'filtri_news', 339 term: term, 340 page: page, 341 nonce: NewsAjax.nonce 342 }, 343 beforeSend: function(){ 344 if (replace) { 345 $results.html('<div class="loading">Loading...</div>'); 346 } else { 347 $load.text('Loading...').prop('disabled', true); 348 } 349 }, 350 success: function(res) { 351 if (!res.success) return; 352 353 // Insert or append 354 if (replace) { 355 $results.html(res.data.html); 356 } else { 357 // assume res.data.html always wraps <div.related_items>â¦</div> 358 var $tmp = $('<div>').append(res.data.html); 359 var newHtml = $tmp.find('.related_items').html(); 360 $results.find('.related_items').append(newHtml); 361 } 362 363 // Update Load More button 364 if (page < res.data.max_pages) { 365 $load 366 .show() 367 .text('Load More') 368 .prop('disabled', false) 369 .data('page', page); 370 } else { 371 $load.hide(); 372 } 373 }, 374 error: function() { 375 if (replace) { 376 $results.html('<p>Errore durante il caricamento.</p>'); 377 } else { 378 $load.text('Errore, riprova').prop('disabled', false); 379 } 380 } 381 }); 382 } 383 384 // Filter buttons 385 $module.on('click', '.filter-btn', function(){ 386 var $btn = $(this); 387 currentTerm = $btn.data('term'); 388 currentPage = 1; 389 390 // Toggle active 391 $module.find('.filter-btn').removeClass('active'); 392 $btn.addClass('active'); 393 394 // Fetch & replace 395 fetchRecipes(currentTerm, currentPage, true); 396 }); 397 398 // Load More button 399 $load.on('click', function(){ 400 var nextPage = ( $(this).data('page') || currentPage ) + 1; 401 currentPage = nextPage; 402 fetchRecipes(currentTerm, currentPage, false); 403 }); 404 } 405 406 if ($(".griglia_press")[0]) { 407 // Cache selectors 408 var $grid = $('.griglia_press'), 409 $module = $grid.find('.ricette-filtri'), // you can leave this if you need it for layout 410 $results = $module.find('#recipes-results'), 411 $load = $('#load-more'); 412 413 // State 414 var currentPage = 1; 415 416 // Common fetch function 417 function fetchPress(page, replace) { 418 $.ajax({ 419 url: PressAjax.ajax_url, 420 type: 'POST', 421 dataType: 'json', 422 data: { 423 action: 'filtri_press', // matches your PHP hook 424 page: page, 425 nonce: PressAjax.nonce 426 }, 427 beforeSend: function(){ 428 if (replace) { 429 $results.html('<div class="loading">Loading...</div>'); 430 } else { 431 $load.text('Loading...').prop('disabled', true); 432 } 433 }, 434 success: function(res) { 435 if (!res.success) return; 436 437 // Insert or append 438 if (replace) { 439 $results.html(res.data.html); 440 } else { 441 var $tmp = $('<div>').append(res.data.html), 442 newHtml = $tmp.find('.related_items').html(); 443 $results.find('.related_items').append(newHtml); 444 } 445 446 // Update Load More button 447 if (page < res.data.max_pages) { 448 $load 449 .show() 450 .text('Load More') 451 .prop('disabled', false) 452 .data('page', page); 453 } else { 454 $load.hide(); 455 } 456 }, 457 error: function() { 458 if (replace) { 459 $results.html('<p>Errore durante il caricamento.</p>'); 460 } else { 461 $load.text('Errore, riprova').prop('disabled', false); 462 } 463 } 464 }); 465 } 466 467 // Initial load (if desired) 468 fetchPress(1, true); 469 470 // Load More button 471 $load.on('click', function(){ 472 var nextPage = ( $(this).data('page') || currentPage ) + 1; 473 currentPage = nextPage; 474 fetchPress(nextPage, false); 475 }); 476 } 477 478 479 if ($(".modulo-contatti")[0]){ 480 /** 481 * initMap 482 *
483 * Renders a Google Map onto the selected jQuery element 484 * 485 * @date 22/10/19 486 * @since 5.8.6 487 * 488 * @param jQuery $el The jQuery element. 489 * @return object The map instance. 490 */ 491 function initMap( $el ) { 492 493 // Find marker elements within map. 494 var $markers = $el.find('.marker'); 495 496 // Create gerenic map. 497 var mapArgs = { 498 zoom : $el.data('zoom') || 16, 499 mapTypeId : google.maps.MapTypeId.ROADMAP 500 }; 501 var map = new google.maps.Map( $el[0], mapArgs ); 502 503 // Add markers. 504 map.markers = []; 505 $markers.each(function(){ 506 initMarker( $(this), map ); 507 }); 508 509 // Center map based on markers. 510 centerMap( map ); 511 512 // Return map instance. 513 return map; 514 } 515 516 /** 517 * initMarker 518 * 519 * Creates a marker for the given jQuery element and map. 520 * 521 * @date 22/10/19 522 * @since 5.8.6 523 * 524 * @param jQuery $el The jQuery element. 525 * @param object The map instance. 526 * @return object The marker instance. 527 */ 528 function initMarker( $marker, map ) { 529 530 // Get position from marker. 531 var lat = $marker.data('lat'); 532 var lng = $marker.data('lng'); 533 var latLng = { 534 lat: parseFloat( lat ), 535 lng: parseFloat( lng ) 536 }; 537 538 // Create marker instance. 539 var marker = new google.maps.Marker({ 540 position : latLng, 541 map: map 542 }); 543 544 // Append to reference for later use. 545 map.markers.push( marker ); 546 547 // If marker contains HTML, add it to an infoWindow. 548 if( $marker.html() ){ 549 550 // Create info window. 551 var infowindow = new google.maps.InfoWindow({ 552 content: $marker.html() 553 }); 554 555 // Show info window when marker is clicked. 556 google.maps.event.addListener(marker, 'click', function() { 557 infowindow.open( map, marker ); 558 }); 559 } 560 } 561 562 /** 563 * centerMap 564 * 565 * Centers the map showing all markers in view. 566 * 567 * @date 22/10/19 568 * @since 5.8.6 569 * 570 * @param object The map instance. 571 * @return void 572 */ 573 function centerMap( map ) { 574 575 // Create map boundaries from all map markers. 576 var bounds = new google.maps.LatLngBounds(); 577 map.markers.forEach(function( marker ){ 578 bounds.extend({ 579 lat: marker.position.lat(), 580 lng: marker.position.lng() 581 }); 582 }); 583 584 // Case: Single marker. 585 if( map.markers.length == 1 ){ 586 map.setCenter( bounds.getCenter() ); 587 588 // Case: Multiple markers. 589 } else{ 590 map.fitBounds( bounds ); 591 } 592 } 593 594 // Render maps on page load. 595 $(document).ready(function(){ 596 $('.acf-map').each(function(){ 597 var map = initMap( $(this) ); 598 }); 599 }); 600 } 601 602 603 if ($(".percorsi_map_interna")[0]){ 604 /** 605 * initMap 606 * 607 * Renders a Google Map onto the selected jQuery element 608 * 609 * @date 22/10/19 610 * @since 5.8.6 611 * 612 * @param jQuery $el The jQuery element. 613 * @return object The map instance. 614 */ 615 function initMap( $el ) { 616 617 // Find marker elements within map. 618 var $markers = $el.find('.marker'); 619 620 // Create gerenic map. 621 var mapArgs = { 622 zoom : $el.data('zoom') || 16, 623 mapTypeId : google.maps.MapTypeId.ROADMAP 624 }; 625 var map = new google.maps.Map( $el[0], mapArgs ); 626 627 // Add markers. 628 map.markers = []; 629 $markers.each(function(){ 630 initMarker( $(this), map ); 631 }); 632 633 // Center map based on markers. 634 centerMap( map ); 635 636 // Return map instance. 637 return map; 638 } 639 640 /** 641 * initMarker 642 * 643 * Creates a marker for the given jQuery element and map. 644 * 645 * @date 22/10/19 646 * @since 5.8.6 647 * 648 * @param jQuery $el The jQuery element. 649 * @param object The map instance. 650 * @return object The marker instance. 651 */ 652 function initMarker( $marker, map ) { 653 654 // Get position from marker. 655 var lat = $marker.data('lat'); 656 var lng = $marker.data('lng'); 657 var latLng = { 658 lat: parseFloat( lat ), 659 lng: parseFloat( lng ) 660 }; 661 662 // Create marker instance. 663 var marker = new google.maps.Marker({ 664 position : latLng, 665 map: map 666 }); 667 668 // Append to reference for later use. 669 map.markers.push( marker ); 670 671 // If marker contains HTML, add it to an infoWindow. 672 if( $marker.html() ){ 673
674 // Create info window. 675 var infowindow = new google.maps.InfoWindow({ 676 content: $marker.html() 677 }); 678 679 // Show info window when marker is clicked. 680 google.maps.event.addListener(marker, 'click', function() { 681 infowindow.open( map, marker ); 682 }); 683 } 684 } 685 686 /** 687 * centerMap 688 * 689 * Centers the map showing all markers in view. 690 * 691 * @date 22/10/19 692 * @since 5.8.6 693 * 694 * @param object The map instance. 695 * @return void 696 */ 697 function centerMap( map ) { 698 699 // Create map boundaries from all map markers. 700 var bounds = new google.maps.LatLngBounds(); 701 map.markers.forEach(function( marker ){ 702 bounds.extend({ 703 lat: marker.position.lat(), 704 lng: marker.position.lng() 705 }); 706 }); 707 708 // Case: Single marker. 709 if( map.markers.length == 1 ){ 710 map.setCenter( bounds.getCenter() ); 711 712 // Case: Multiple markers. 713 } else{ 714 map.fitBounds( bounds ); 715 } 716 } 717 718 // Render maps on page load. 719 $(document).ready(function(){ 720 $('.acf-map').each(function(){ 721 var map = initMap( $(this) ); 722 }); 723 }); 724 } 725 726 // Adjust ScrollTop Offset 727 function adjustScroll(target) { 728 if (target.length) { 729 var topOffset = 20; 730 if ($('#wpadminbar').length) { 731 topOffset += $('#wpadminbar').outerHeight(); 732 } 733 if ($('.site-header').length) { 734 topOffset += $('.site-header').outerHeight(); 735 } 736 setTimeout(function() { 737 $('html, body').animate({ 738 scrollTop: target.offset().top - topOffset 739 }, 500); 740 }, 50); 741 } 742 } 743 744 // Handle clicks on anchor links within the page 745 $(document).on('click', 'a[href*="#"]', function(event) { 746 // Do nothing if inside sf-field-reset 747 if ($(this).closest('.sf-field-reset').length) { 748 return; 749 } 750 var href = $(this).attr('href'); 751 var hashIndex = href.indexOf('#'); 752 if (hashIndex > -1) { 753 var hash = href.substring(hashIndex); 754 var target = $(hash); 755 event.preventDefault(); 756 757 if (target.length) { 758 adjustScroll(target); 759 } else { 760 window.location = href; 761 } 762 } 763 }); 764 765 // Handle direct navigation to a URL with a hash 766 $(window).on('load', function() { 767 if (window.location.hash) { 768 var target = $(window.location.hash); 769 if (target.length) { 770 setTimeout(function() { 771 adjustScroll(target); 772 }, 100); 773 } 774 } 775 }); 776 777 // Accordion 778 $('.accordion').each(function () { 779 var $accordion = $(this); // the current .accordion 780 $accordion.find('dl > dt').on('click keydown', function(event) { 781 if (event.type === 'keydown' && ![13,32].includes(event.keyCode)) return; 782 783 var $dl = $(this).closest('dl'); // only this <dl> 784 var $dd = $(this).next('dd'); 785 var isOpen = $(this).hasClass('on'); 786 787 // toggle _this_ header & panel 788 $(this) 789 .toggleClass('on', !isOpen) 790 .attr('aria-expanded', !isOpen); 791 $dd 792 .slideToggle() 793 .attr('aria-hidden', isOpen); 794 795 // close _other_ headers in _this_ accordion only 796 $dl 797 .find('dt.on') 798 .not(this) 799 .removeClass('on') 800 .attr('aria-expanded', false) 801 .next('dd') 802 .slideUp() 803 .attr('aria-hidden', true); 804 805 event.preventDefault(); 806 }); 807 }); 808 809});
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.