TGAMD=window.TGAMD||{},TGAMD.CanvasAd=function(a){"use strict";function b(){return this.el?this.el.length>0:!1}function c(a){if(0===a.length)return null;var b=a.outerHeight(!0),c=Math.ceil(a.offset().top),d=c+b;return{height:b,top:c,bottom:d}}function d(){var d=b.call(h),e={};return a(f.children().get().reverse()).each(function(){var b=a(this),c=Math.ceil(b.offset().top);if(c<=l.offsetTop){if(d!==!0)return e.target=b,!1;if(c>=h.dimensions.bottom)return e.target=b,!1}}),void 0!==e.target&&(l.resize(),e.target.after('
'),e.el=a(".js-canvas-ad__placeholder"),e.el.css({height:i.height,margin:"0 0 30px"}),e.dimensions=c(e.el)),e}function e(e,m){if(i.src=m.src||null,i.height=m.height||null,i.src&&i.height){f=a(j.body).first(),g=a(j.boxAd),h.el=f.find(j.aside),h.dimensions=c(h.el),l.el=a(e),l.clear().getOffsetTop();var n=d();if(!b.call(n))return void console.error("Could not find appropriate placeholder for canvas ad. Likely that the article body is to short when compared against the length of the article rail");var o=Math.ceil(n.dimensions.top-l.offsetTop);o>0?l.alignWithPlaceholder(o):0>o&&g.length>0&&g.height()>300&&(k=a(j.trailingContent).get(1),a(k).css({marginTop:Math.abs(o)+"px"})),l.serve();var p=a(j.canvas.wrapper),q=a(j.canvas.close);p.css({height:i.height}).show(),q.on("click",function(){a(this).remove(),p.remove(),n.el.remove(),l.el.remove(),null!==k&&a(k).css({marginTop:0})})}}var f,g,h={el:null},i={src:null,height:null},j={body:".entry-content .column-2",aside:".entry-sidebar",trailingContent:".entry-content .x140x460",boxAd:"#boxr-art-1",canvas:{wrapper:".canvas-ad__wrapper",close:".canvas-ad__closebtn"}},k=null,l={alignWithPlaceholder:function(a){var b=(a||0)+20;this.el.attr("style",function(a,c){return c+" margin-top: "+b+"px;"})},clear:function(){return this.el.empty().attr("style","height: 0 !important; min-height: 0;"),this},getOffsetTop:function(){this.offsetTop=Math.ceil(this.el.offset().top)},resize:function(){this.el.attr("style","position: relative; height: "+i.height+"px !important;")},serve:function(){var a='';a=a.replace("#{src}",i.src).replace("#{height}",i.height),this.el.prepend(a)}};return{init:function(b,c){a(window).on("load",function(){e(b,c)})}}}(window.jQuery); //# sourceMappingURL=canvas.js.map