Current File : /var/www/pediatribu/wp-content/cache/wpo-minify/tmp/js-bb4126e2.js.transient |
{"request":{"hurl":"https:\/\/pediatribu.org\/wp-content\/plugins\/ultimate-addons-for-gutenberg\/assets\/js\/post.js","inline":"","enable_minification":true,"type":"js","handle":"uagb-post-js","version":"2.19.9"},"log":{"url":"\/wp-content\/plugins\/ultimate-addons-for-gutenberg\/assets\/js\/post.js","success":true},"code":"let loadStatus=!0;window.UAGBPostCarousel={_setHeight(scope){if(scope.length>0){const postWrapper=scope[0].querySelectorAll('.slick-slide'),postActive=scope[0].querySelectorAll('.slick-slide.slick-active');let maxHeight=-1,wrapperHeight=-1,postActiveHeight=-1;Object.keys(postActive).forEach((key)=>{const thisHeight=postActive[key].offsetHeight,blogPost=postActive[key].querySelector('.uagb-post__inner-wrap'),blogPostHeight=blogPost?.offsetHeight;if(maxHeight<blogPostHeight){maxHeight=blogPostHeight;postActiveHeight=maxHeight+15}\nif(wrapperHeight<thisHeight){wrapperHeight=thisHeight}});Object.keys(postActive).forEach((key)=>{const selector=postActive[key].querySelector('.uagb-post__inner-wrap');if(selector){selector.style.height=maxHeight+'px'}});let selector=scope[0].querySelector('.slick-list');if(selector){selector.style.height=postActiveHeight+'px'}\nmaxHeight=-1;wrapperHeight=-1;Object.keys(postWrapper).forEach((key)=>{const $this=postWrapper[key];if($this.classList.contains('slick-active')){return!0}\nselector=$this.querySelector('.uagb-post__inner-wrap');const blogPostHeight=selector?.offsetHeight;if(blogPostHeight){selector.style.height=blogPostHeight+'px'}})}},_unSetHeight(scope){if(scope.length>0){const postWrapper=scope[0].querySelectorAll('.slick-slide'),postActive=scope[0].querySelectorAll('.slick-slide.slick-active');Object.keys(postActive).forEach((key)=>{const selector=postActive[key].querySelector('.uagb-post__inner-wrap');selector.style.height='auto'});Object.keys(postActive).forEach((key)=>{const $this=postWrapper[key];if($this.classList.contains('slick-active')){return!0}\nconst selector=$this.querySelector('.uagb-post__inner-wrap');selector.style.height='auto'})}},};window.UAGBPostMasonry={_init($attr,$selector){let count=2;const windowHeight50=window.innerHeight\/1.25;let $scope=document.querySelector($selector);const loader=$scope?.querySelectorAll('.uagb-post-inf-loader');if('none'!==$attr.paginationType&&'scroll'===$attr.paginationEventType){window.addEventListener('scroll',function(){let postItems=$scope.querySelector('.uagb-post__items');if(!postItems){postItems=$scope}\nconst boundingClientRect=postItems.lastElementChild.getBoundingClientRect();const offsetTop=boundingClientRect.top+window.scrollY;if(window.pageYOffset+windowHeight50>=offsetTop){const $args={page_number:count,};const total=$scope.getAttribute('data-total');if(!0===loadStatus){if(count<=total){if(loader.length>0){loader[0].style.display='none'}\nwindow.UAGBPostMasonry._callAjax($scope,$args,$attr,loader,!1,count);count++;loadStatus=!1}}}})}\nif('button'===$attr.paginationEventType){if($scope?.querySelector('.uagb-post-pagination-button')){$scope.style.marginBottom='40px';$scope.querySelector('.uagb-post-pagination-button').onclick=function(){$scope=this.closest('.uagb-post-grid');const total=$scope.getAttribute('data-total');const $args={total,page_number:count,};$scope.querySelector('.uagb-post__load-more-wrap').style.display='none';if(!0===loadStatus){if(count<=total){if(loader.length>0){loader[0].style.display='none'}\n$scope.querySelector('.uagb-post__load-more-wrap').style.display='block';window.UAGBPostMasonry._callAjax($scope,$args,$attr,loader,!0,count);count++;loadStatus=!1}}}}}},createElementFromHTML(htmlString){const HTMLElement=document.createElement('div');HTMLElement.innerHTML=htmlString.trim();return HTMLElement},_callAjax($scope,$obj,$attr,loader,append=!1,count){const PostData=new FormData();PostData.append('action','uagb_get_posts');PostData.append('nonce',uagb_data.uagb_masonry_ajax_nonce);PostData.append('page_number',$obj.page_number);PostData.append('attr',JSON.stringify($attr));fetch(uagb_data.ajax_url,{method:'POST',credentials:'same-origin',body:PostData,}).then((resp)=>resp.json()).then(function(data){let element=$scope.querySelector('.is-masonry');if(!element){element=$scope}\nsetTimeout(function(){const isotope=new Isotope(element,{itemSelector:'article',});isotope.insert(window.UAGBPostMasonry.createElementFromHTML(data.data));loadStatus=!0;if(loader.length>0){loader[0].style.display='none'}\nif(!0===append){$scope.querySelector('.uagb-post__load-more-wrap').style.display='block'}\nif(count===parseInt($obj.total)){$scope.querySelector('.uagb-post__load-more-wrap').style.display='none'}\nconst articles=document.querySelectorAll('.uagb-post__image-position-background .uagb-post__inner-wrap');for(const article of articles){const articleWidth=article.offsetWidth;const rowGap=$attr.rowGap;const imageWidth=100-(rowGap\/articleWidth)*100;const image=article.getElementsByClassName('uagb-post__image');if(image[0]){image[0].style.width=imageWidth+'%';image[0].style.marginLeft=rowGap\/2+'px'}}},500)}).catch(function(error){console.log(JSON.stringify(error))})},};window.UAGBPostGrid={_callAjax($attr,$page_number,block_id){const PostData=new FormData();PostData.append('action','uagb_post_pagination_grid');PostData.append('nonce',uagb_data.uagb_grid_ajax_nonce);PostData.append('page_number',$page_number);PostData.append('attr',JSON.stringify($attr));fetch(uagb_data.ajax_url,{method:'POST',credentials:'same-origin',body:PostData,}).then((resp)=>resp.json()).then(function(data){const grid_element=document.querySelector('.uagb-block-'+block_id);if(!grid_element){return}\nconst html=data.data.replace(\/\\n|\\t\/g,'');grid_element.outerHTML=html;const new_blockId=html.match(\/uagb-block-([\\w-]+)\/)?.[1]||'';addClickListeners(new_blockId)});function addClickListeners(new_blockId){const elements=document.querySelectorAll(`.uagb-post-grid.uagb-block-${new_blockId} .uagb-post-pagination-wrap a`);elements.forEach(element=>{element.addEventListener('click',event=>{event.preventDefault();const link=event.target.getAttribute('href').match(\/admin-ajax.*\/)?.[0]||'';const pageNumber=link.match(\/\\d+\/)?.[0]||1;window.UAGBPostGrid._callAjax($attr,parseInt(pageNumber),new_blockId)})})}}};function uagb_carousel_height(id){const wrap=document.querySelector('#wpwrap .is-carousel.uagb-block-'+id);if(wrap){window.UAGBPostCarousel._setHeight(wrap)}}\nfunction uagb_carousel_unset_height(id){const wrap=document.querySelector('#wpwrap .is-carousel.uagb-block-'+id);if(wrap){window.UAGBPostCarousel._unSetHeight(wrap)}};\n","status":true}