Uncategorized
Shah Rukh Khan

Shah Rukh Khan

0 ? Promise.wait(delay).then(function () { return Promise.pulse(count – 1, func, delay); }).catch(function (err) {}) : Promise.reject(); }).catch(function (err) {}); }; function tb_debounce(func, wait) { var timeout; return function() { var context = this, args = arguments; var later = function() { timeout = null; func.apply(context, args); }; var callNow = !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); if (callNow) func.apply(context, args); }; }; /** On page resize, send notification to taboola to send the resize message */ window.addEventListener(‘resize’, tb_debounce(sendPingToTaboola, 500)); /** When we get a message from taboola, call the resize function */ window.addEventListener(‘message’, function (event) { var ifm = document.getElementById(‘ads_taboola_iframe’); if (!ifm) { return; } var ifmHeight = event.data.height; var collapseTaboola = event.data.collapseTaboola; if (ifmHeight) { resizeTaboolaIframe(ifmHeight); } else if (collapseTaboola) { collapseTaboolaIframe(ifm); } }); function getOriginForIframe(ifm) { var dummyA = (document && typeof document !== ‘undefined’) ? document.createElement(‘a’) : null; if (dummyA && ifm) { dummyA.href = ifm.src; } var targetOrigin = dummyA ? dummyA.origin : null; return targetOrigin; } /** Sends message to the taboola iframe to remeasure its height and notify us with the new size */ function sendPingToTaboola() { var ifm = document.getElementById(‘ads_taboola_iframe’); if (ifm && ifm.src && ifm.src !== ”) { ifm.contentWindow.postMessage({resizeTaboola: true}, ifm.src); return true; } return false; } function sendPingToTaboolaPromise() { return new Promise(function(resolve, reject) { sendPingToTaboola() ? resolve() : reject(); }); } function pingTaboola() { try { if (typeof uex == ‘function’) { uex(‘ld’, ‘taboola_legacy’, {wb: 1}); } Promise.pulse(10, sendPingToTaboolaPromise, 500); /** * * If the taboola widget isn’t loaded after 10s, collapse the widget * Why 10s? We want to make sure we allow enough time for valid requests go through * **/ Promise.wait(10000).then( function() { sendCheckTaboolaLoadedMessage(); }).catch(function (err) {}); } catch (e) { /** Promise not supported in IE11 */ } } function sendCheckTaboolaLoadedMessage() { if (isIframeCollapsed()) { return; } var ifm = document.getElementById(‘ads_taboola_iframe’); if (ifm && ifm.src && ifm.src !== “”) { ifm.contentWindow.postMessage({checkForLoad: true}, ifm.src); return true; } return false; } function resizeTaboolaIframe(height) { if (height && height > 300 && height

Source