jQuery(document).ready(function ($) { // var limit = jQuery('div#my-events-list input.loadlimitdata').val(); // console.log('loadContent'); // jQuery.ajax({ // type: "post", // url: ajax_var.url, // data: "action=" + ajax_var.action + "&nonce=" + ajax_var.nonce+ "&limitpost=" + limit, // success: function(result){ // jQuery('#my-events-list').html(result); // } // }); // CATEGORIES // Music // Culture // Entertainment // Food-Drink // Arts // Cannabis var initialpost = ''; var success = 'true'; var holdLoad = 'false'; var holdLoadInitial = 'false'; var holdLoadCat = 'false'; // var load_cat = general function loadEventsAjax(){ // AJAX LOAD success = 'false'; jQuery('.initialpost').prependTo('div#my-events-list'); if(holdLoadInitial == 'false'){ console.log('ENTRO'); jQuery('.loader.loadEventseffs').fadeIn(); jQuery('.gridloadsec').addClass('gridSectionLoad'); jQuery('div#my-button').addClass('gridSectionLoad'); holdLoadInitial = 'true'; } jQuery('div#evr-grid').addClass('grid'); jQuery('.media-box').addClass('media-box-load'); jQuery('.media-boxes-grid-sizer').addClass('media-boxes-grid-sizer-load'); function resizeGridItem(item){ grid = document.getElementsByClassName("grid")[0]; rowHeight = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-auto-rows')); rowGap = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-row-gap')); rowSpan = Math.ceil((item.querySelector('.media-box-container').getBoundingClientRect().height+rowGap)/(rowHeight+rowGap)); item.style.gridRowEnd = "span "+rowSpan; } function resizeAllGridItems(){ allItems = document.getElementsByClassName("media-box"); for(x=0;x'+result+''); }else{ jQuery('#evr-grid').append(result); } var totalResult = jQuery(result).length; // if exist filter, filter for new load if(jQuery('a.alldatafilterMusic').hasClass('selected')){ // jQuery('a.alldatafilterMusic').click(); }else if (jQuery('a.alldatafilterFood-Drink').hasClass('selected')) { // jQuery('a.alldatafilterFood-Drink').click(); }else if (jQuery('a.alldatafilterArts').hasClass('selected')) { // jQuery('a.alldatafilterArts').click(); }else if (jQuery('a.alldatafilterEntertainment').hasClass('selected')) { // jQuery('a.alldatafilterEntertainment').click(); }else if (jQuery('a.alldatafilterCulture').hasClass('selected')) { // jQuery('a.alldatafilterCulture').click(); }else if (jQuery('a.alldatafilterCannabis').hasClass('selected')) { // jQuery('a.alldatafilterCannabis').click(); } jQuery('.gridloadsec').removeClass('gridSectionLoad'); jQuery('div#my-button').removeClass('gridSectionLoad'); jQuery('.loader.loadEventseffs').fadeOut(); success = 'true'; } }); } // Music // Culture // Entertainment // Food-Drink // Arts // Cannabis jQuery('a.alldatafilter').click(function(e) { // jQuery('.initialpost').prependTo('div#my-events-list'); jQuery("section.cb-entry-content div#my-button").text("load events"); jQuery('div#evr-grid').removeClass('nomoreload'); jQuery('div#nomore-evnts').hide(); jQuery('.initialpost').val(''); jQuery('div#my-events-list').append(''); jQuery('div#my-events-list').append(''); jQuery('div#evr-grid .media-box').remove(); jQuery('.filterdatacategory').val('all'); jQuery('section.cb-entry-content').removeClass('nomoreload loadNomore'); holdLoad = 'false'; holdLoadInitial = 'false'; prevenholdLoad = 'true'; holdLoadCat = 'true'; console.log('ENTRO ALL'); // reset temporal load jQuery('.temp_load').remove(); loadEventsAjax(); }); jQuery('a.alldatafilterMusic').click(function(e) { // jQuery('.initialpost').prependTo('div#my-events-list'); jQuery("section.cb-entry-content div#my-button").text("load events"); jQuery('div#evr-grid').removeClass('nomoreload'); jQuery('div#nomore-evnts').hide(); jQuery('.initialpost').val(''); jQuery('.offsetData').val('0'); jQuery('.tempSubdate').val(''); jQuery('.initialpost').prependTo('div#my-events-list'); jQuery('div#evr-grid .media-box').remove(); jQuery('.filterdatacategory').val('Music'); jQuery('section.cb-entry-content').removeClass('nomoreload loadNomore'); holdLoad = 'false'; holdLoadInitial = 'false'; prevenholdLoad = 'true'; holdLoadCat = 'true'; console.log('ENTRO MUSIC22'); // reset temporal load jQuery('.temp_load').remove(); loadEventsAjax(); }); jQuery('a.alldatafilterFood-Drink').click(function(e) { jQuery("section.cb-entry-content div#my-button").text("load events"); jQuery('div#evr-grid').removeClass('nomoreload'); jQuery('div#nomore-evnts').hide(); jQuery('.initialpost').prependTo('div#my-events-list'); jQuery('.initialpost').val(''); jQuery('.offsetData').val('0'); jQuery('.tempSubdate').val(''); jQuery('div#evr-grid .media-box').remove(); jQuery('.filterdatacategory').val('Food-Drink'); jQuery('section.cb-entry-content').removeClass('nomoreload loadNomore'); holdLoad = 'false'; holdLoadInitial = 'false'; prevenholdLoad = 'true'; holdLoadCat = 'true'; console.log('ENTRO FOOD'); // reset temporal load jQuery('.temp_load').remove(); loadEventsAjax(); }); jQuery('a.alldatafilterArts').click(function(e) { jQuery("section.cb-entry-content div#my-button").text("load events"); jQuery('div#evr-grid').removeClass('nomoreload'); jQuery('div#nomore-evnts').hide(); jQuery('.initialpost').val(''); jQuery('.offsetData').val('0'); jQuery('.tempSubdate').val(''); jQuery('.initialpost').prependTo('div#my-events-list'); jQuery('div#evr-grid .media-box').remove(); jQuery('.filterdatacategory').val('Arts'); jQuery('section.cb-entry-content').removeClass('nomoreload loadNomore'); holdLoad = 'false'; holdLoadInitial = 'false'; prevenholdLoad = 'true'; holdLoadCat = 'true'; console.log('ENTRO ARTS'); // reset temporal load jQuery('.temp_load').remove(); loadEventsAjax(); }); jQuery('a.alldatafilterEntertainment').click(function(e) { jQuery("section.cb-entry-content div#my-button").text("load events"); jQuery('div#evr-grid').removeClass('nomoreload'); jQuery('div#nomore-evnts').hide(); jQuery('.initialpost').val(''); jQuery('.offsetData').val('0'); jQuery('.tempSubdate').val(''); jQuery('.initialpost').prependTo('div#my-events-list'); jQuery('div#evr-grid .media-box').remove(); jQuery('.filterdatacategory').val('Entertainment'); jQuery('section.cb-entry-content').removeClass('nomoreload loadNomore'); holdLoad = 'false'; holdLoadInitial = 'false'; prevenholdLoad = 'true'; holdLoadCat = 'true'; console.log('ENTRO Entertainment'); // reset temporal load jQuery('.temp_load').remove(); loadEventsAjax(); }); jQuery('a.alldatafilterCulture').click(function(e) { jQuery("section.cb-entry-content div#my-button").text("load events"); jQuery('div#evr-grid').removeClass('nomoreload'); jQuery('div#nomore-evnts').hide(); jQuery('.initialpost').val(''); jQuery('.offsetData').val('0'); jQuery('.tempSubdate').val(''); jQuery('.initialpost').prependTo('div#my-events-list'); jQuery('div#evr-grid .media-box').remove(); jQuery('.filterdatacategory').val('Culture'); jQuery('section.cb-entry-content').removeClass('nomoreload loadNomore'); holdLoad = 'false'; holdLoadInitial = 'false'; prevenholdLoad = 'true'; holdLoadCat = 'true'; console.log('ENTRO CULTURE'); // reset temporal load jQuery('.temp_load').remove(); loadEventsAjax(); }); jQuery('a.alldatafilterCannabis').click(function(e) { jQuery("section.cb-entry-content div#my-button").text("load events"); jQuery('div#evr-grid').removeClass('nomoreload'); jQuery('div#nomore-evnts').hide(); jQuery('.initialpost').val(''); jQuery('.offsetData').val('0'); jQuery('.tempSubdate').val(''); jQuery('.initialpost').prependTo('div#my-events-list'); jQuery('div#evr-grid .media-box').remove(); jQuery('.filterdatacategory').val('Cannabis'); jQuery('section.cb-entry-content').removeClass('nomoreload loadNomore'); holdLoad = 'false'; holdLoadInitial = 'false'; prevenholdLoad = 'true'; holdLoadCat = 'true'; console.log('ENTRO CANNABIS'); // reset temporal load jQuery('.temp_load').remove(); loadEventsAjax(); }); // END CATEGORIES var dataScrolling = ''; var dataLoad = 'false'; var prevenholdLoad = 'true'; jQuery(window).scroll(function(event) { event.stopPropagation(); var dataScrolling = jQuery(window).scrollTop() + jQuery(window).height() -1500; if(jQuery("div#my-button").length){ if(jQuery(window).scrollTop() >= jQuery('div#my-button').offset().top - 800 && success == 'true'){ if(jQuery('section.cb-entry-content').hasClass('nomoreload')){ // console.log('tiene nomoreload'); // jQuery('.temp_load>div').appendTo('#evr-grid'); // jQuery('.temp_load').remove(); }else{ if(holdLoad == 'true'){ if( prevenholdLoad == 'false' ){ prevenholdLoad = 'true'; jQuery('.temp_load>div').appendTo('#evr-grid'); jQuery('.temp_load').remove(); jQuery('.gridloadsec').addClass('gridSectionLoad'); jQuery('div#my-button').addClass('gridSectionLoad'); jQuery('.loader.loadEventseffs').fadeIn(); setTimeout(function(){ console.log('ENTRO RELOAD3'); jQuery('.gridloadsec').removeClass('gridSectionLoad'); jQuery('div#my-button').removeClass('gridSectionLoad'); jQuery('.loader.loadEventseffs').fadeOut(); loadEventsAjax(); setTimeout(function(){ prevenholdLoad = 'false'; }, 1000); }, 2000); } }else{ if( holdLoadCat == 'true' ){ console.log('ENTRO RELOADCat2'); holdLoadInitial = 'false'; loadEventsAjax(); holdLoadCat == 'false'; setTimeout(function(){ loadEventsAjax(); holdLoad = 'true'; prevenholdLoad = 'false'; console.log('ENTRO RELOAD22'); }, 3500); }else{ loadEventsAjax(); setTimeout(function(){ loadEventsAjax(); holdLoad = 'true'; prevenholdLoad = 'false'; console.log('ENTRO RELOAD2'); }, 3500); } } // console.log('ENTRO RELOAD FALSO'); } // if(jQuery('section.cb-entry-content').hasClass('nomoreload')){ // console.log('tiene nomoreload'); // }else if(holdLoad == 'false';){ // loadEventsAjax(); // console.log('ENTRO RELOAD FALSO'); // }else if(holdLoad == 'false';){ // setTimeout(function(){ // loadEventsAjax(); // holdLoad = 'true'; // console.log('ENTRO RELOAD2'); // }, 1500); // } } } }); });