!function(t){"use strict";var e=function(e,n){this.content_container=".post-wrapper",this.content_class=".post-autoload",this.grecaptcha=".g-recaptcha",this.current_url=window.location.href,this.post_cache=[],this.is_sidefeed=!!t("#jeg_sidecontent").length,this.sidefeed=t(".jeg_sidefeed"),this.change_url_locked=!1,this.is_sidefeed=!this.sidefeed.hasClass("sidefeed_sidebar")&&this.is_sidefeed,t(document).on("jnews-sidefeed-ajax",t.proxy(this.clear_post_cache,this)),t(document).on("jnews-sidefeed-ajax-begin",t.proxy(this.lock_change_url,this)),this.init()};e.DEFAULTS={},e.prototype.lock_change_url=function(){this.change_url_locked=!0},e.prototype.init=function(){this.initialise_waypoint()},e.prototype.clear_post_cache=function(){var t=this;t.change_url_locked=!1,t.post_cache=[],t.initialise_waypoint()},e.prototype.find_prev_post=function(e){return(e=t(e).next()).length?e.hasClass("jeg_post")?e:this.find_prev_post(e):null},e.prototype.get_previous_url=function(e,n){var o=this;if(o.is_sidefeed&&"sidefeed"===jnewsoption.autoload_content||o.is_sidefeed&&window.jnews&&window.jnews.sidefeed&&window.jnews.sidefeed.variable.include_category){var i=o.sidefeed.find('[data-id="'+n+'"]'),a=o.find_prev_post(i);return a?t(a).find("a.ajax").attr("href"):null}return t(e).data("prev")},e.prototype.initialise_waypoint=function(){var e=this;t(e.content_class).each((function(){t(this).hasClass("loaded")||(t(this).addClass("loaded").waypoint((function(n){if(!e.change_url_locked){t.proxy(e.change_url,e,this.element,n).call()}}),{offset:"0%",context:window}),t(this).find(".jnews-autoload-splitter").waypoint((function(n){if(!e.change_url_locked){var o=t(this.element).parents(".post-wrap");t.proxy(e.change_url,e,o,n).call()}}),{offset:"0%",context:window}))}))},e.prototype.strip_html=function(t){var e=document.createElement("DIV");return e.innerHTML=t,e.textContent||e.innerText||""},e.prototype.change_url=function(e,n){var o=this,i=t(e),a=i.data("url"),s=i.data("title"),d=i.data("id"),r=o.get_previous_url(i,d);if(o.current_url!=a){o.current_url=a,history&&history.pushState&&(history.pushState(null,s,a),document.title=o.strip_html(s)),window.jnews&&window.jnews.ajax_analytic&&jnews.ajax_analytic.update(a,d),t(document).trigger("jnews-autoload-change-id",[d]);var c=t('[data-id="'+d+'"]').find(".comment_disqus");c.length&&o.disqus_comment(c)}if(jnewsoption.autoload_limit&&t(o.content_class).length>parseInt(jnewsoption.autoload_limit))return!1;r&&"down"===n&&o.auto_load_prev_post(r,d)},e.prototype.disqus_comment=function(e){t(".comment_disqus").empty(),e.append('<div id="disqus_thread"></div>'),DISQUS.reset({reload:!0})},e.prototype.render_recaptcha=function(){Array.from(t(this.content_container).find(this.grecaptcha).last()).forEach((function(t){grecaptcha.render(t,t.dataset.sitekey)}))},e.prototype.check_loaded=function(t){return this.post_cache.indexOf(t)>-1},e.prototype.push_post_id=function(t){this.post_cache.push(t)},e.prototype.auto_load_prev_post=function(e,n){var o=this,i=null;if(e&&!o.check_loaded(n)){if(jnews.loginregister.init(),o.push_post_id(n),e.indexOf("?p=")>-1)i=e+"&autoload=1&exclude="+JSON.stringify(jnewsautoload);else{var a="autoload/?exclude="+JSON.stringify(jnewsautoload);"/"!=e.charAt(e.length-1)&&(a="/"+a),i=e+a}jnewsautoload.push(n),t.get(i,(function(e){t(o.content_container).append(e),o.initialise_waypoint(),t(document).trigger("jnews-ajax-load",[t(o.content_container).find(o.content_class).last()]),o.render_recaptcha()}))}};var n=t.fn.jautoload;t.fn.jautoload=function(n){return t(this).each((function(){var o=t(this),i=t.extend({},e.DEFAULTS,o.data(),"object"==typeof n&&n),a=o.data("jeg.autoload");a||o.data("jeg.autoload",a=new e(i))}))},t.fn.jautoload.Constructor=e,t.fn.jautoload.noConflict=function(){return t.fn.jautoload=n,this},t(document).on("ready",(function(){t("body").jautoload()})),window.jnewsautoload=[]}(jQuery);