function layoutMasonry(e){var t=$(".parallax"),n=t.width();t.css("height",n*.7),$(".bb-join-block").is(":visible")==1?e.masonry("stamp",$(".bb-join-block")):e.masonry("unstamp",$(".bb-join-block")),e.masonry("layout"),$(".sign-up-btn-number").slabText({fontRatio:.9})}function shiftParallaxImages(){$(".parallax img").each(function(e){var t=$(window).scrollTop(),n=t+$(window).height(),r=$(this).parent().offset().top,i=r+$(this).parent().height();rt&&$(this).css({transform:"translateY("+(t-r)*25/($(window).height()-$(this).parent().height()).toFixed()+"px)"})})}$.urlParam=function(e){var t=(new RegExp("[?&]"+e+"=([^&#]*)")).exec(window.location.href);return t==null?null:t[1]||0},$(function(){function t(){var t=$.urlParam("article-id");if(t!=null){$(".article-card-"+t).removeClass("compact").addClass("expanded"),layoutMasonry(e),setTimeout(function(){layoutMasonry(e)},500);var n=$(".article-card-"+t).filter(":visible:first").first().offset().top-140;$("html, body").animate({scrollTop:n+"px"},"fast"),$(window).width()>560&&$("#article-details-"+t).modal("show")}}$("[data-toggle=relatedTopicsPopover]").popover({html:!0,content:function(){return $("#popover-content").html()}}),$("[data-toggle=articleRelatedTopicsPopover]").popover({html:!0,container:"body",content:function(){return $(this).parent().find(".article-related-topics").html()}}),$("[data-toggle=articleRelatedTopicsPopover]").on("shown.bs.popover",function(){initializeKeywordButtons()});var e=$(".grid").masonry({itemSelector:".bb-article-block",stamp:".bb-join-block",columnWidth:".grid-sizer"});layoutMasonry(e),e.imagesLoaded().always(function(){layoutMasonry(e),t()}),$(window).resize(function(){layoutMasonry(e)}),$(window).scroll(function(){shiftParallaxImages()}),$(".open-article-details").click(function(){var t=$(this).closest(".bb-article-block");t.removeClass("compact").addClass("expanded"),layoutMasonry(e),setTimeout(function(){layoutMasonry(e)},500)}),$(".editable").editable(function(e,t){var n=e,r=$(this),i=r.data("variable"),s=r.data("entity");return $.ajax({type:"POST",url:articleScoreModifierUrl,dataType:"json",data:{variable:i,entity:s,newValue:e},success:function(e){e&&e.newValue&&(n=e.newValue),location.reload()},error:function(e,t,n){window.alert("Error "+e.status+": "+n),location.reload()}}),n},{type:"text",submit:"OK"})})