File: /home/e/z/p/ezpgggd/www/wp-content/themes/generatepress_child/assets/js/circolare.js
$ = jQuery;
var circolare = $("#circolare_filter_search");
var circolareForm = circolare.find("form");
var year = " ";
var categoria = " ";
var month = " ";
var search = " ";
var keyword = " ";
$( ".view-all" ).click(function() {
$('#circolare_filter_search form')[0].reset();
$("#circolare_filter_search form").submit();
});
function search_ajax() {
if(circolareForm.find("#year").val().length !== 0) {
year = $( "#year" ).val();
}
if(circolareForm.find("#month").val().length !== 0) {
month = $( "#month" ).val();
}
if(circolareForm.find("#categoria").val().length !== 0) {
categoria = $( "#categoria" ).val();
}
if(circolareForm.find("#search").val().length !== 0) {
search = circolareForm.find("#search").val();
}
var data = {
action : "circolare_filter_search",
year: year,
month: month,
categoria: categoria,
search: search
}
console.log(data);
$.ajax({
url : ajax_url,
data : data,
success : function(response) {
circolare.find("#circolare_filter_search_results").empty();
if(response) {
// var count = "" + response.length + " items";
// circolare.find("#circolare_filter_search_results_count").css('display', 'block').empty().append(count);
for(var i = 0 ; i < response.length ; i++) {
var html = '<div class="col-md-4">';
html += '<article class="lae-module lae-module post-'+response[i].id+' circolare type-post status-publish format-standard has-post-thumbnail ast-article-single">';
html += '<div class="elementor elementor-2088 post-'+response[i].id+' post type-post status-publish format-standard has-post-thumbnail hentry category-sin-categoria ast-article-single">';
html += '<div class="elementor-section-wrap"><section class="elementor-section elementor-top-section elementor-element elementor-element-17ff6f6a elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="17ff6f6a" data-element_type="section"><div class="elementor-container elementor-column-gap-default"><div class="elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-eb5d49" data-id="eb5d49" data-element_type="column"><div class="elementor-widget-wrap elementor-element-populated"><div class="elementor-element elementor-element-174e546c elementor-widget elementor-widget-theme-post-featured-image elementor-widget-image" data-id="174e546c" data-element_type="widget" data-widget_type="theme-post-featured-image.default">';
html += '<div class="elementor-widget-container">';
if (response[i].image != false) {
html += '<a href="'+response[i].permalink+'">';
html += '<img src="'+response[i].image+'" class="attachment-full size-full" alt="" loading="lazy" srcset="'+response[i].image+' 657w, '+response[i].image+'-300x300.png 300w, '+response[i].image+'-150x150.png 150w" sizes="(max-width: 657px) 100vw, 657px" width="657" height="657"></a>';
}
html += '</div></div><div class="elementor-heading-title elementor-size-default"><a href="'+response[i].permalink+'">'+response[i].title+'</a></div>';
html += '<div class="elementor-element elementor-element-6032c5e5 elementor-widget elementor-widget-theme-post-title elementor-page-title elementor-widget-heading" data-id="6032c5e5" data-element_type="widget" data-widget_type="theme-post-title.default">';
html += '<div class="guarda-online-button">';
html += '<a href="'+response[i].permalink+'"><button>GUARDA ONLINE</button></a>';
html += '</div>';
if (response[i].pdf != false) {
html += '<div class="scarica-circolare-button">';
html += '<a href="'+response[i].pdf+'"><i aria-hidden="true" class="far fa-file-pdf"></i><span class="elementor-button-text">SCARICA CIRCOLARE</span></a>';
html += '</div>';
}
html += '</div>';
html += '<div class="elementor-element elementor-element-2e18954e fecha-post elementor-widget elementor-widget-post-info" data-id="2e18954e" data-element_type="widget" data-widget_type="post-info.default"><div class="elementor-widget-container"><ul class="elementor-inline-items elementor-icon-list-items elementor-post-info">';
html += '<li class="elementor-icon-list-item elementor-repeater-item-8f20702 elementor-inline-item" itemprop="datePublished"><span class="elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-date">'+response[i].date+'</span></li>';
html += '</ul></div></div>';
// html += '<p>'+response[i].excerpt+'</p>';
html += '<div class="elementor-element elementor-element-57721d8e elementor-widget elementor-widget-button" data-id="57721d8e" data-element_type="widget" data-widget_type="button.default">';
html += '<div class="elementor-widget-container"><span class="guion">— </span>';
html += response[i].cats;
html += '</div>';
html += '</div></div></div></div></section></div></article></div>';
// var html = 'hello world';
circolare.find("#circolare_filter_search_results").append(html);
}
} else {
circolare.find("#circolare_filter_search_results_count").css('display', 'none');
var html = "<div class='no-match'>Nessuna circolare trovata. Prova un filtro diverso";
circolare.find("#circolare_filter_search_results").append(html);
}
}
});
}
$('#circolare_filter_search select').change(function() {
search_ajax();
});
$('#circolare_filter_search #submit').click(function() {
search_ajax();
});