!function($){var Scroller,ajaxurl,stats,type,text,totop,isIE=-1!=navigator.userAgent.search("MSIE");if(isIE){var IEVersion=navigator.userAgent.match(/MSIE\s?(\d+)\.?\d*;/);IEVersion=parseInt(IEVersion[1],10)}Scroller=function(e){var t=this;this.id=e.id,this.body=$(document.body),this.window=$(window),this.element=$("#"+e.id),this.wrapperClass=e.wrapper_class,this.ready=!0,this.disabled=!1,this.page=1,this.offset=e.offset,this.currentday=e.currentday,this.order=e.order,this.throttle=!1,this.handle=1<e.handle.length?(text=text.replace("\\",""),e.handle.replace(RegExp("{text}","g"),text)):'<div id="infinite-handle"><span><button>'+text.replace("\\","")+"</button></span></div>",this.appendHandleTo=e.appendHandleTo.length<1||1!=$(e.appendHandleTo).length?this.element:$(e.appendHandleTo),this.click_handle=e.click_handle,this.google_analytics=e.google_analytics,this.history=e.history,this.origURL=window.location.href,this.pageCache={},this.footer=$("#infinite-footer"),this.footer.wrap=e.footer,this.wpMediaelement=null,this.minWidthForDetermineUrl=void 0===e.minWidthForDetermineUrl?575:e.minWidthForDetermineUrl,this.doDetermineUrl=!this.matchMedia(this.minWidthForDetermineUrl),"scroll"==type?(this.window.on("scroll.infinity",function(){this.throttle=!0}),t.gotop(),setInterval(function(){this.throttle&&(this.throttle=!1,t.thefooter(),t.refresh(),t.determineURL())},250),t.ensureFilledViewport(),this.body.on("post-load",{self:t},t.checkViewportOnLoad)):"click"==type&&(this.click_handle&&this.appendHandleTo.append(this.handle),this.body.delegate("#infinite-handle","click.infinity",function(){t.click_handle&&$("#infinite-handle").remove(),t.refresh()})),this.body.on("post-load",{self:t},t.initializeMejs)},Scroller.prototype.check=function(){var e=this.element.offset();if("object"!=typeof e)return!1;var t=2.5*(this.window.scrollTop()+this.window.height());return this.element.outerHeight(!1)+e.top<t},Scroller.prototype.render=function(e){this.body.addClass("infinity-success"),this.element.append(e.html),this.body.trigger("post-load",e),this.ready=!0},Scroller.prototype.query=function(){return{page:this.page,currentday:this.currentday,order:this.order,scripts:window.infiniteScroll.settings.scripts,styles:window.infiniteScroll.settings.styles,query_args:window.infiniteScroll.settings.query_args,last_post_date:window.infiniteScroll.settings.last_post_date,is_home:window.infiniteScroll.settings.is_home}},Scroller.prototype.gotop=function(){var e=$("#infinity-blog-title");e.attr("title",totop),e.on("click",function(e){$("html, body").animate({scrollTop:0},"fast"),e.preventDefault()})},Scroller.prototype.thefooter=function(){var e;"string"==typeof this.footer.wrap&&479<(e=$("body #"+this.footer.wrap).outerWidth(!1))&&this.footer.find(".container").css("width",e),350<=this.window.scrollTop()?this.footer.animate({bottom:0},"fast"):this.window.scrollTop()<350&&this.footer.animate({bottom:"-50px"},"fast")},Scroller.prototype.refresh=function(){var self=this,query,jqxhr,load,loader,color,customized;if(!this.disabled&&this.ready&&this.check()){if(this.ready=!1,this.click_handle){loader='<span class="infinite-loader" style="width: 100%; bottom: 0; position:absolute"></span>',this.element.append(loader),loader=this.element.find(".infinite-loader"),color=loader.css("color");try{loader.spin("medium-left",color)}catch(e){}}return query=$.extend({action:"infinite_scroll"},this.query()),"undefined"!=typeof wp&&wp.customize&&wp.customize.settings.theme&&(customized={},query.wp_customize="on",query.theme=wp.customize.settings.theme.stylesheet,wp.customize.each(function(e){e._dirty&&(customized[e.id]=e())}),query.customized=JSON.stringify(customized),query.nonce=wp.customize.settings.nonce.preview),jqxhr=$.post(infiniteScroll.settings.ajaxurl,query),jqxhr.fail(function(){self.click_handle&&loader.hide(),self.ready=!0}),jqxhr.done(function(response){if(self.click_handle&&loader.hide(),response&&response.type&&"success"==response.type){if(response.scripts&&$(response.scripts).each(function(){var e=this.footer?"body":"head";if(window.infiniteScroll.settings.scripts.push(this.handle),this.extra_data){var t=document.createElement("script"),i=document.createTextNode("//<![CDATA[ \n"+this.extra_data+"\n//]]>");t.type="text/javascript",t.appendChild(i),document.getElementsByTagName(e)[0].appendChild(t)}var o=document.createElement("script");o.type="text/javascript",o.src=this.src,o.id=this.handle,"wp-mediaelement"===this.handle&&self.body.off("post-load",self.initializeMejs),"wp-mediaelement"===this.handle&&"undefined"==typeof mejs?(self.wpMediaelement={},self.wpMediaelement.tag=o,self.wpMediaelement.element=e,setTimeout(self.maybeLoadMejs.bind(self),250)):document.getElementsByTagName(e)[0].appendChild(o)}),response.styles&&$(response.styles).each(function(){window.infiniteScroll.settings.styles.push(this.handle);var style=document.createElement("link");style.rel="stylesheet",style.href=this.src,style.id=this.handle+"-css",!this.conditional||isIE&&eval(this.conditional.replace(/%ver/g,IEVersion))||(style=!1),style&&document.getElementsByTagName("head")[0].appendChild(style)}),self.page!=response.pageNum)return self.body.addClass("infinity-success"),self.click_handle&&loader.hide(),void(self.ready=!0);if(self.pageCache[self.page]=response,self.page++,stats&&((new Image).src=document.location.protocol+"//pixel.wp.com/g.gif?"+stats+"&post=0&baba="+Math.random()),"object"==typeof response.postflair&&"object"==typeof WPCOM_sharing_counts&&(WPCOM_sharing_counts=$.extend(WPCOM_sharing_counts,response.postflair)),self.render.apply(self,arguments),"click"==type?response.lastbatch?self.click_handle?($("#infinite-handle").remove(),self.body.addClass("infinity-end").removeClass("infinity-success")):self.body.trigger("infinite-scroll-posts-end"):self.click_handle?self.appendHandleTo.append(self.handle):self.body.trigger("infinite-scroll-posts-more"):response.lastbatch&&(self.disabled=!0,self.body.addClass("infinity-end").removeClass("infinity-success"),self.click_handle&&loader.remove()),response.currentday&&(self.currentday=response.currentday),self.google_analytics){var ga_url=self.history.path.replace(/%d/,self.page);"object"==typeof _gaq&&_gaq.push(["_trackPageview",ga_url]),"function"==typeof ga&&ga("send","pageview",ga_url)}}}),jqxhr}},Scroller.prototype.maybeLoadMejs=function(){null!==this.wpMediaelement&&("undefined"==typeof mejs?setTimeout(this.maybeLoadMejs.bind(this),250):(document.getElementsByTagName(this.wpMediaelement.element)[0].appendChild(this.wpMediaelement.tag),this.wpMediaelement=null,this.body.on("post-load",{self:this},this.initializeMejs)))},Scroller.prototype.initializeMejs=function(e,t){!t.html||-1===t.html.indexOf("wp-audio-shortcode")&&-1===t.html.indexOf("wp-video-shortcode")||"undefined"!=typeof mejs&&$(function(){var e={};"undefined"!=typeof _wpmejsSettings&&(e.pluginPath=_wpmejsSettings.pluginPath),e.success=function(e){var t=e.attributes.autoplay&&"false"!==e.attributes.autoplay;"flash"===e.pluginType&&t&&e.addEventListener("canplay",function(){e.play()},!1)},$(".wp-audio-shortcode, .wp-video-shortcode").not(".mejs-container").mediaelementplayer(e)})},Scroller.prototype.ensureFilledViewport=function(){var e=this,t=e.window.height(),i=e.element.height(),o=0,s=0;0!==i||($(e.element.selector+" > li").each(function(){i+=$(this).height()}),0!==i)?($("."+e.wrapperClass).each(function(){o+=$(this).height(),s++}),0<s?o/=s:o=0,i<t&&i+o<t?(e.ready=!0,e.refresh()):e.body.off("post-load",e.checkViewportOnLoad)):e.body.off("post-load",e.checkViewportOnLoad)},Scroller.prototype.checkViewportOnLoad=function(e){e.data.self.ensureFilledViewport()},Scroller.prototype.determineURL=function(){if(this.doDetermineUrl){var t=this,n=$(window).scrollTop(),l=n+$(window).height(),r=l-n,a=[],d=[],c=!1;if($("."+t.wrapperClass).each(function(){var e,t=$(this).attr("id"),i=$(this).offset().top,o=$(this).outerHeight(!1),s=$(this).data("page-num");0===o&&$("> *",this).each(function(){o+=$(this).outerHeight(!1)}),e=i+o,i<n&&l<e?a.push({id:t,top:i,bottom:e,pageNum:s,where:"in-view"}):n<i&&i<l?a.push({id:t,top:i,bottom:e,pageNum:s,where:"in-view"}):n<e&&e<l?a.push({id:t,top:i,bottom:e,pageNum:s,where:"in-view"}):d.push({id:t,top:i,bottom:e,pageNum:s,where:e<n?"before":"after"})}),$.each(d,function(){var e=$("#"+this.id);e.hasClass("is--replaced")||(e.trigger("before-endlessly-caching",{candidates_for_caching:e}).delay(0),t.pageCache[this.pageNum].html=e.html(),e.css("min-height",this.bottom-this.top+"px").addClass("is--replaced").empty())}),$.each(a,function(){var e=$("#"+this.id);e.trigger("before-endlessly-replace",{set:e}).delay(0),e.hasClass("is--replaced")&&(e.css("min-height","").removeClass("is--replaced"),this.pageNum in t.pageCache&&(e.html(t.pageCache[this.pageNum].html),t.body.trigger("post-load",t.pageCache[this.pageNum])))}),0===a.length)c=-1;else if(1==a.length){var e=a.pop();c=(l-e.top)/r<.5?-1:e.pageNum}else{var p=0;$.each(a,function(e,t){var i=0,o=0,s=0;t.top>n&&t.top<l&&(i=(l-t.top)/r),t.bottom>n&&t.bottom<l&&(o=(t.bottom-n)/r),o<=i?s=i:i<=o&&(s=o),p<s&&(c=t.pageNum,p=s)})}"number"==typeof c&&(-1!=c&&c++,t.updateURL(c))}},Scroller.prototype.matchMedia=function(e){return window.matchMedia?window.matchMedia("(max-width: "+e+"px)").matches:$(window).width()<=e-15},Scroller.prototype.updateURL=function(e){if(window.history.pushState){var t=this,i=0<t.offset?t.offset-1:0,o=-1==e?t.origURL:window.location.protocol+"//"+t.history.host+t.history.path.replace(/%d/,e+i)+t.history.parameters;window.location.href!=o&&history.pushState(null,null,o)}},Scroller.prototype.pause=function(){this.disabled=!0},Scroller.prototype.resume=function(){this.disabled=!1},$(document).ready(function(){if("object"==typeof infiniteScroll){if("https:"==document.location.protocol&&(infiniteScroll.settings.ajaxurl=infiniteScroll.settings.ajaxurl.replace("http://","https://")),$(document.body).addClass(infiniteScroll.settings.body_class),ajaxurl=infiniteScroll.settings.ajaxurl,stats=infiniteScroll.settings.stats,type=infiniteScroll.settings.type,type=Scroller.prototype.matchMedia(1024)?infiniteScroll.settings.isClickTypeOnMobile?"click":type:infiniteScroll.settings.isClickTypeOnDesktop?"click":type,text=infiniteScroll.settings.text,totop=infiniteScroll.settings.totop,"products"!==infiniteScroll.settings.postType?infiniteScroll.scroller=new Scroller(infiniteScroll.settings):"click"!=type&&(infiniteScroll.scroller=new Scroller(infiniteScroll.settings)),"click"==type){var e=null;$(window).on("scroll",function(){e||(e=setTimeout(function(){infiniteScroll.scroller.determineURL(),e=null},250))})}"undefined"!=typeof wp&&wp.customize&&wp.customize.selectiveRefresh&&(wp.customize.selectiveRefresh.bind("partial-content-rendered",function(e){var t;"string"==typeof e.addedContent?t=e.addedContent:e.container&&(t=$(e.container).html()),t&&$(document.body).trigger("post-load",{html:t})}),"undefined"==typeof MutationObserver&&$(document.body).on("post-load",function(e,t){var i=null;t.html&&-1!==t.html.indexOf("data-customize-partial")&&(infiniteScroll.settings.id&&(i=$("#"+infiniteScroll.settings.id)),wp.customize.selectiveRefresh.addPartials(i))}))}})}(jQuery);