openstuck/hs files/Homestuck_files/manifest-ads-story-bb655d0d...

1 line
2.8 KiB
JavaScript

function openStoryAd(){MetaModals.toggle("#metamodal-story-ad"),adjustStoryAd(),Tracking.sendEvent({category:"Read",action:"Open Story Ad",label:getGAEventLabel()});setTimeout(function(){googletag.cmd.push(function(){googletag.display("story-ad")})},250),setTimeout(function(){adjustStoryAd()},750),setTimeout(function(){checkStoryAdFilled()},1e3)}function adjustStoryAd(){var t=$("#metamodal-story-ad"),e=window.innerHeight?window.innerHeight:$(window).height(),o=$("#story-ad iframe"),a=(o.contents(),o.contents().find("a")),d=o.contents().find("a img");if(!0===$.browser.mobile&&0!=window.orientation&&e<290)var n=210,i=175;else n=300,i=250;d.width(n),a.width(n),o.width(n),t.width(n),d.height(i),o.height(i),a.height(i),t.height(i+40);var s=($(window).width()-t.outerWidth())/2,l=(e-t.outerHeight())/2;t.css({left:s,top:l})}function checkStoryAdFilled(){adRendered&&!adFilled&&MetaModals.toggle("#metamodal-story-ad")}var googletag=googletag||{};googletag.cmd=googletag.cmd||[],function(){var t=document.createElement("script");t.async=!0,t.type="text/javascript";var e="https:"==document.location.protocol;t.src=(e?"https:":"http:")+"//www.googletagservices.com/tag/js/gpt.js";var o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(t,o)}(),function(t,o){o(function(){MetaModals.reset()}),o(document).on("keyup",function(t){if(27==t.keyCode){var e=o(".metamodal[data-metamodal-state='on']");e.length&&MetaModals.doCloseAction(e)}})}(0,jQuery);var adRendered=!(MetaModals={reset:function(){var t=$("[data-metamodal-btn]");t.off("click"),t.on("click",function(t){t.preventDefault(),MetaModals.toggle($(this).attr("href"))})},resetState:function(){$("[data-metamodal-state]").attr("data-metamodal-state","off")},close:function(){$("#nav-container").attr("data-nav-state","closed"),$("#overlay").css({"z-index":"4"}).attr("data-overlay-state","off").off(),$("input",".metamodal[data-metamodal-state='on']").blur(),MetaModals.resetState()},toggle:function(t){var e=$(t),o=e.attr("data-metamodal-state"),a=$("#overlay");"on"==o?MetaModals.close():($("#nav-container").attr("data-nav-state","off"),a.attr("data-overlay-state","off").off(),MetaModals.resetState(),e.attr("data-metamodal-state","on"),a.css({"z-index":"7"}).attr("data-overlay-state","on"),e.css({top:$(window).scrollTop()+$(window).height()/2+"px"}),e.scrollTop(0),a.on("click",function(){MetaModals.doCloseAction(e)}))},doCloseAction:function(t){var e=$(".metamodal-close",t);e.length?e.click():MetaModals.close()}}),adFilled=!1;googletag.cmd.push(function(){googletag.defineSlot("/17331515/Homestuck_Story",[300,250],"story-ad").addService(googletag.pubads()),googletag.pubads().addEventListener("slotRenderEnded",function(t){t.isEmpty||(adFilled=!0),adRendered=!0}),googletag.enableServices()}),$(document).ready(function(){var t=20,e=+getCookie("hs-pg-ck")||1;t<=e?deleteCookie("hs-pg-ck"):setCookie("hs-pg-ck",e+1,365)});