!function(t){"use strict";var e=function(e,n){this.content_container=".post-wrapper",this.content_class=".post-autoload",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(){this.change_url_locked=!1,this.post_cache=[],this.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){if(this.is_sidefeed&&"sidefeed"===jnewsoption.autoload_content||this.is_sidefeed&&window.jnews&&window.jnews.sidefeed&&window.jnews.sidefeed.variable.include_category){var i=this.sidefeed.find('[data-id="'+n+'"]'),o=this.find_prev_post(i);return o?t(o).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 i=t(this.element).parents(".post-wrap");t.proxy(e.change_url,e,i,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 i=t(e),o=i.data("url"),a=i.data("title"),s=i.data("id"),d=this.get_previous_url(i,s);if(this.current_url!=o){this.current_url=o,history&&history.pushState&&(history.pushState(null,a,o),document.title=this.strip_html(a)),window.jnews&&window.jnews.ajax_analytic&&jnews.ajax_analytic.update(o,s),t(document).trigger("jnews-autoload-change-id",[s]);var r=t('[data-id="'+s+'"]').find(".comment_disqus");r.length&&this.disqus_comment(r)}if(jnewsoption.autoload_limit&&t(this.content_class).length>parseInt(jnewsoption.autoload_limit))return!1;d&&"down"===n&&this.auto_load_prev_post(d,s)},e.prototype.disqus_comment=function(e){t(".comment_disqus").empty(),e.append('
'),DISQUS.reset({reload:!0})},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 i=this,o=null;if(e&&!i.check_loaded(n)){if(jnews.loginregister.init(),i.push_post_id(n),e.indexOf("?p=")>-1)o=e+"&autoload=1";else{var a="autoload/";"/"!=e.charAt(e.length-1)&&(a="/"+a),o=e+a}t.get(o,(function(e){t(i.content_container).append(e),i.initialise_waypoint(),t(document).trigger("jnews-ajax-load",[t(i.content_container).find(i.content_class).last()])}))}};var n=t.fn.jautoload;t.fn.jautoload=function(n){return t(this).each((function(){var i=t(this),o=t.extend({},e.DEFAULTS,i.data(),"object"==typeof n&&n),a=i.data("jeg.autoload");a||i.data("jeg.autoload",a=new e(o))}))},t.fn.jautoload.Constructor=e,t.fn.jautoload.noConflict=function(){return t.fn.jautoload=n,this},t(document).on("ready",(function(){t("body").jautoload()}))}(jQuery);