jQuery(document).ready(function($) {
$('.ecs-event-pagination').on("click", "a", function () {
event.preventDefault();
$('#eventfeed_current_pagination_page').val();
$("input[name='eventfeed_current_pagination_page']").val($(this).attr("pn"));
setTimeout(() => {
checkImagesLoad();
}, 2000);
});
$('.decm_event_display_0').addClass("eventsGridview");
var setHeightColumns = function(){
var column_loop_row = 0;
var column_height = 0;
var overlay_height = 0;
var ids = [];
var total_Count = 0;
var total_Events = jQuery('.decm_event_display_0 .ecs-event-posts').length;
jQuery('.decm_event_display_0 .ecs-event-posts').each(function(){
++column_loop_row;
++total_Count;
var Event_id = jQuery(this).children('article')[0].id;
ids.push(Event_id);
column_height = jQuery(this).find('#'+Event_id).children('.row').height() >= column_height ? jQuery(this).find('#'+Event_id).children('.row').height() : column_height;
overlay_height =
jQuery(this).find('.decm-cover-overlay-details').height() >= overlay_height ? jQuery(this).find('.decm-cover-image-overlay').height() : overlay_height;
if(column_loop_row == 3 || total_Count == total_Events)
{
ids.map(function(id,index){
var tempHeight = parseInt(column_height) - parseInt(jQuery('.decm_event_display_0 #'+id+' .row > div:first-child').height());jQuery('.decm_event_display_0 #'+id+' .decm-cover-overlay-details').css('height',overlay_height);
});
column_loop_row = 0;
column_height = 0;
ids = [];
}
});
jQuery('.decm_event_display_0 p.ecs-showdetail').css({"position":"static","bottom":"auto","width":"100%","left":"auto","right":"auto","marginTop":"auto"});
}
var checkImagesLoad = function(){
Promise.all(
Array.from(jQuery(".decm_event_display_0 .ecs-event-posts img")).
filter(img => !img.complete).
map(img => new Promise(resolve => {
img.onload = img.onerror = resolve;
}))).then(() => {
setHeightColumns();
});
/*var imgs = jQuery(".decm_event_display_0_tb_body .ecs-event-posts img"),
len = imgs.length,
counter = 0;
[].forEach.call( imgs, function( img ) {
if(img.complete)
incrementCounter();
else
img.addEventListener( "load", incrementCounter, false );
} );
function incrementCounter() {
counter++;
if ( counter === len ) {
debugger;
setHeightColumns();
}
}*/
}
setTimeout(checkImagesLoad, 2000);
jQuery(window).on('resize',function(){
var screenWidth = jQuery(this).width();
if(screenWidth > 1199){
if(document.readyState == 'complete')
checkImagesLoad();
}
else{
jQuery('.decm_event_display_0 .ecs-event-posts').each(function(){
var id = jQuery(this).children('article')[0].id;
jQuery('.decm_event_display_0 #'+id+' .row > div:first-child').css({height:'auto'});
jQuery('.decm_event_display_0 #'+id+' .row > div:last-child').css({height:'auto',minHeight:0,overflow:'visible'});
jQuery('.decm_event_display_0 #'+id+' .row > div > div:last-child').css({height:'auto',minHeight:0,overflow:'visible'});
jQuery('.decm_event_display_0 #'+id+' p.ecs-showdetail').css({position:'static',bottom:'auto',width:'100%',left:'auto',right:'auto',marginTop:'auto'});
});
jQuery('.decm_event_display_0 p.ecs-showdetail').css({"position":"static","bottom":"auto","width":"100%","left":"auto","right":"auto","marginTop":"auto"});
}
});
});