News and Events

Church Preen Primary School

Our Newsletters

Latest News

 

Content Coming Soon!

Our Events

No Events

/* made by Rashel Roqibul */ (function(){ var MAX = 10; function q(sel, root){ return (root||document).querySelector(sel); } function qa(sel, root){ return Array.prototype.slice.call((root||document).querySelectorAll(sel)); } function getItems(wrap){ return qa('.eventon_list_event, .evo_event_list .eventon_list_event, .ajde_evcal_list .eventon_list_event, .evo_event', wrap); } function getNativeLoadMore(wrap){ return q('.evo_load_more, .evo_load_more_events, .ajde_evcal_calendar .evcal_btn_load_more', wrap); } function ensureOurButton(wrap){ if (q('.ev-load-more', wrap)) return; var btn = document.createElement('a'); btn.href = 'javascript:void(0);'; btn.className = 'ev-load-more et_pb_button et_pb_button_0 et_pb_bg_layout_light'; btn.textContent = 'View more'; btn.style.cssText = ` display: inline-block !important; margin: 20px auto !important; text-align: center !important; cursor: pointer !important; padding: 10px 30px !important; `; wrap.appendChild(btn); btn.addEventListener('click', function(){ loadAllMonths(wrap, function(){ getItems(wrap).forEach(function(el){ el.style.display = ''; }); btn.remove(); }); }); } function applyInitialLimit(wrap){ var items = getItems(wrap); if (items.length === 0) return false; items.forEach(function(el, i){ el.style.display = (i < MAX) ? '' : 'none'; }); ensureOurButton(wrap); return true; } function loadAllMonths(wrap, done){ var attempts = 0, maxAttempts = 50; function clickOnce(next){ var btn = getNativeLoadMore(wrap); if (!btn || btn.disabled || btn.classList.contains('loading')) return next(false); (btn.querySelector('a,button') || btn).click(); var mo = new MutationObserver(function(){ mo.disconnect(); next(true); }); mo.observe(wrap, {childList:true, subtree:true}); setTimeout(function(){ try{mo.disconnect();}catch(e){} next(true); }, 3000); } (function loop(){ if (++attempts > maxAttempts) return done(); clickOnce(function(loaded){ var btn = getNativeLoadMore(wrap); if (!btn || btn.disabled) return done(); setTimeout(loop, 200); }); })(); } function init(){ var wrap = q('.ev-limit-10'); if (!wrap) return; var tries = 30; (function tick(){ if (applyInitialLimit(wrap)) return; if (--tries > 0) return setTimeout(tick, 300); var mo = new MutationObserver(function(){ applyInitialLimit(wrap); }); mo.observe(wrap, {childList:true, subtree:true}); })(); } if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init); else init(); })();