(function() { var offerCtaButtonList = document.querySelectorAll(".js-offer-cta"); if( null !== offerCtaButtonList ){ offerCtaButtonList.forEach(function( offerCtaButton) { /** * on offer cta click event */ offerCtaButton.addEventListener('click', e => { //90 days cookie expiry. var now = new Date(); now.setDate( now.getDate() + 90); //set referer url in cookie document.cookie = "et_offer_referer_url="+window.location.href+"; expires=" + now.toUTCString() + ";path=/;"; }); }); } })();; var adiInit = "69781", adiRVO = true; var adiFunc = null; (function() { var adiSrc = document.createElement("script"); adiSrc.type = "text/javascript"; adiSrc.async = true; adiSrc.src = ("https:" == document.location.protocol ? "https://static-ssl" : "http://static-cdn")+ ".responsetap.com/static/scripts/rTapTrack.min.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(adiSrc, s); })();; jQuery(function($) { /** * The desktop breakpoint defined for ads placement * @type {number} */ const adDesktopWidth = 1024; /** * Variables needed for adPlaceholder functions * @type {number} */ let adTravelCounter = 1; let adTravelNativeCounter = 1; let adTravelNativeGroupCounter = 1; // we disable PHPCS because we need actual HTML to be placed on pages // this will not be user input // phpcs:disable /** * Generate the add placement div with proper class and attributes * @returns {jQuery|HTMLElement|*} */ function adTravelPlaceholder() { let item = $('
', { id: 'ad-travel-' + adTravelCounter, class:'nuk-ad-placeholder', 'data-ad-label':'channel' }) adTravelCounter++ return item; } /** * Generate the add placement div for travel native group * with proper children and attributes * @returns {*|jQuery|HTMLElement} */ function adTravelNativeBlockPlacehoder() { let travelNativeParentDiv = $('
', { class: 'ad-native-wrapper group-' + adTravelNativeGroupCounter }) // append main title travelNativeParentDiv.append( $('

', { text: 'Sponsored' }) ) // append 4 child element inside for (let i = adTravelNativeCounter; i < adTravelNativeCounter + 4; i++) { travelNativeParentDiv.append( $('
', { id: 'advert-travel-native-' + i, 'data-parent': 'group-' + adTravelNativeGroupCounter }) ); } adTravelNativeCounter = adTravelNativeCounter + 4; adTravelNativeGroupCounter++ // return everything back together. return travelNativeParentDiv; } /** * Generate the add placement div for article native block * with proper class and attributes * @returns {jQuery|HTMLElement|*} */ function adArticleNativePlaceholder() { let travelNativeParentDiv = $('
', { class: 'ad-native-wrapper group-1' }) // append main title travelNativeParentDiv.append( $('

', { text: 'Sponsored' }) ) // append 4 child element inside for (let i = 1; i < 3; i++) { travelNativeParentDiv.append( $('
', { id: 'advert-article-native-' + i, 'data-parent': 'group-1' }) ); } return travelNativeParentDiv; } /** * Generate the add placement div with proper class and attributes * for inline article ads * @returns {jQuery|HTMLElement|*} */ function adArticleTravelPlaceholder() { return $('
', { id: 'ad-intravelarticle-inline', class:'nuk-ad-placeholder', 'data-ad-label':'channel' }) } /** * Generate the add placement div with proper class and attributes * for pixelskin element * @returns {jQuery|HTMLElement|*} */ function adPixelskinPlaceholder() { return $('
', { id: 'ad-pixelskin' }) } /** * Generate the add placement div with proper class and attributes * for pixel element * @returns {jQuery|HTMLElement|*} */ function adPixelPlaceholder() { return $('
', { id: 'ad-pixel' }) } /** * This goes to all pages above header */ $('body').prepend( $('
', { id: 'ad-header' }) ); /** * This goes to all pages next to H1 element */ $('h1').append( $('', { id: 'ad-times-travel-partnership-logo' }) ); /** * On footer of all pages */ $('footer').prepend( adPixelskinPlaceholder() ); $('footer').prepend( adPixelPlaceholder() ); /** * Homepage logic */ if ( $('body').hasClass('home') ) { // BOTH MOBILE AND DESKTOP // count blocks let blocks = $('.widget_section'); // After 1st Block if (blocks.length >= 1) { $(blocks.eq(0)).after( adTravelPlaceholder() ); } // After 3rd Block if (blocks.length >= 3) { $(blocks.eq(2)).after( adTravelNativeBlockPlacehoder() ); } // After the 5th then every subsequent 2 blocks (if exist) if (blocks.length >= 5) { for (let i = 4; i < blocks.length + 1; i += 2) { $(blocks.eq(i)).after( adTravelPlaceholder() ); } } } /** * All other index pages (destination, Cruises, Tours, Holiday types) */ if ( $('body').hasClass('tax-destinations') || $('body').hasClass('tax-holiday-type') ) { // count blocks let blocks = $('.widget_section'); // After 1st Block if (blocks.length >= 1) { $(blocks.eq(0)).after( adTravelPlaceholder() ); } // After the 3rd then every subsequent 2 blocks (if exist) - travel block if (blocks.length >= 3) { for (let i = 2; i < blocks.length + 1; i += 2) { $(blocks.eq(i)).after( adTravelPlaceholder() ); } } // After 2nd Block - native block if (blocks.length >= 2) { $(blocks.eq(1)).after( adTravelNativeBlockPlacehoder() ); } } /** * Articles */ if ( $('body').hasClass('single-article') ) { if ( $('main').hasClass('hide_ads') ) return ; /** * Check screen width then go with either desktop * or mobile and tab version of ads */ if (window.innerWidth >= adDesktopWidth) { placeArticleAddsDesktop(); } else { placeArticleAddsDesktop(); } } /** * Output add units for article post type for mobile and tablet */ function placeArticleAdds() { // count paragraphs let blocks = $('.article__postarea > *'); let articleImagesElements = $('.article__postarea img'); const articleParagraphElements = $('.article__postarea p:not(:has("img"))'); // After the 1st block on the page if (blocks.length >= 2) { $(blocks.eq(1)).after( adArticleTravelPlaceholder() ); } // After the 1st block on the page if (blocks.length >= 3) { $(blocks.eq(3)).after( adArticleNativePlaceholder() ); } } /** * Output add units for article post type desktop screen size only */ function placeArticleAddsDesktop() { $('.article__content').prepend( adPixelskinPlaceholder() ); // count paragraphs let blocks = $('.article__postarea > *'); let articleImagesElements = $('.article__postarea img'); const articleParagraphElements = $('.article__postarea p:not(:has("img"))'); // If the article has fewer than 6 paragraphs, // there will be no ads. if (articleParagraphElements.length <= 5) { return } // If the article has between 6 & 8 Paragraphs, // the ad can be places wrapped in between the content // ads can be placed wrapped between para 5 and 6 if (articleParagraphElements.length >= 6 && articleParagraphElements.length <= 8) { $(blocks.eq(4)).after( adArticleTravelPlaceholder() ); return } // If Article has image/Interactive above and below // the 5th Paragraph, the ad should be placed below // the 5th paragraph, between the paragraph and the // interactive/ad below as a full length rail. let isAdDisplayed = false; if ( articleImagesElements.length ) { let elementBefore = $(articleParagraphElements.eq(4)).prev(); let elementAfter = $(articleParagraphElements.eq(4)).next(); // check if both contain image if ( elementBefore.children('img').length && elementAfter.children('img').length ) { $(articleParagraphElements.eq(5)).after( adArticleTravelPlaceholder() ); isAdDisplayed = true; } } // If the article has more than 8 paragraphs with image or // interactive within first 10 paragraphs, the ads can be // placed wrapped between para 5 and 6 (as shown in image) if ( articleImagesElements.length && articleParagraphElements.length >= 8) { let targetedParagraphIndex = $(blocks).index( articleParagraphElements.eq(8) ); let elementsBefore = blocks.slice(0, targetedParagraphIndex); // check if there is an image within, if yes // inject add slot after 5th if (isAdDisplayed === false) { if ( elementsBefore.children('img') ) { if( $(articleParagraphElements.eq(5)).hasClass('wp-caption-text') ){ $(articleParagraphElements.eq(5).parent()).after( adArticleTravelPlaceholder() ); } else { $(articleParagraphElements.eq(5)).after( adArticleTravelPlaceholder() ); } } else { // if no image inject after 3rd paragraph $(articleParagraphElements.eq(3)).after( adArticleTravelPlaceholder() ); } } } // If article has more than 8 paragraphs, without images or // interactives in the first 10 items , the ad could be placed // as shown after 4th paragraph floated right if ( articleImagesElements.length && articleParagraphElements.length >= 10) { let targetedParagraphIndex = $(blocks).index( articleParagraphElements.eq(10) ); let elementsBefore = blocks.slice(0, targetedParagraphIndex); if ( ! elementsBefore.children('img') && isAdDisplayed === false ) { $(articleParagraphElements.eq(4)).after( adArticleTravelPlaceholder() ); } } // If article has more than 12 paragraphs, and no images // or interactive elements between paragraph 10-13 if ( articleImagesElements.length && articleParagraphElements.length > 12) { let paragraphTen = $(blocks).index( articleParagraphElements.eq(10) ); let paragraphThirteen = $(blocks).index( articleParagraphElements.eq(13) ); let elementsForCheck = blocks.slice(paragraphTen, paragraphThirteen); if ( ! elementsForCheck.children('img') ) { $(articleParagraphElements.eq(10)).after( adArticleNativePlaceholder() ); } } } }); ;