Audio By Carbonatix
`,
“,
“,
“,
“,
“,
“,
“,
“,
“
];
[ { "name": "Air - MediumRectangle - Inline Content - Mobile Display Size", "component": "18478561", "insertPoint": "2", "requiredCountToDisplay": "2", "watchElement": ".fdn-content-body", "astAdList": [ { "adType": "rectangle", "displayTargets": "mobile" } ] },{ "name": "Editor Picks", "component": "16759093", "insertPoint": "4", "requiredCountToDisplay": "1", "watchElement": ".fdn-content-body", "astAdList": [ { "adType": "rectangleLeft", "displayTargets": "desktop|tablet" },{ "adType": "rectangleRight", "displayTargets": "desktop|tablet|mobile" } ] },{ "name": "Inline Links", "component": "17980324", "insertPoint": "8th", "startingPoint": 8, "requiredCountToDisplay": "7", "maxInsertions": 25 },{ "name": "Air - MediumRectangle - Combo - Inline Content", "component": "16759092", "insertPoint": "8th", "startingPoint": 8, "requiredCountToDisplay": "7", "maxInsertions": 25, "watchElement": ".fdn-content-body", "astAdList": [ { "adType": "rectangleLeft", "displayTargets": "desktop|tablet" },{ "adType": "rectangleRight", "displayTargets": "desktop|tablet|mobile" } ] },{ "name": "Inline Links", "component": "17980324", "insertPoint": "8th", "startingPoint": 12, "requiredCountToDisplay": "11", "maxInsertions": 24 },{ "name": "Air - Leaderboard Tower - Combo - Inline Content", "component": "16759094", "insertPoint": "8th", "startingPoint": 12, "requiredCountToDisplay": "11", "maxInsertions": 24, "watchElement": ".fdn-content-body", "astAdList": [ { "adType": "leaderboardInlineContent", "displayTargets": "desktop|tablet" },{ "adType": "tower", "displayTargets": "mobile" } ] } ]
‘)
let lineHeight = jQuery(‘[line-height-check]’).get(0).clientHeight;
jQuery(‘[line-height-check]’).remove()
if (jQuery(element).prop(‘tagName’).match(/HIDDEN/i) !== null) {
jQuery(element).children(‘div’).last().css({ marginBottom: `${lineHeight*2}px` });
}
else {
jQuery(element).css({
marginTop: `${lineHeight*2}px`,
marginBottom: `${lineHeight}px`
});
}
//
const insertionBlockClass = `fdn-paragraph-insertion-block`;
const styleElementHook = `fdn-paragraph-insertion-styles`;
jQuery(element).addClass(insertionBlockClass);
if (jQuery(`[${styleElementHook}]`).length === 0) {
jQuery(‘div.fdn-content-body, div #storyBody’).append(”)
const paragraphLineHeight = jQuery(‘[line-height-check]’).get(0).clientHeight;
jQuery(‘[line-height-check]’).remove()
const styleElement = jQuery(“);
const styleText = `
div.fdn-content-body br+.${insertionBlockClass}:not([hidden]),
div #storyBody br+.${insertionBlockClass}:not([hidden]) {
margin-top: ${paragraphLineHeight*2}px;
margin-bottom: ${paragraphLineHeight}px;
}
div.fdn-content-body br+.${insertionBlockClass}[hidden] > div:last-of-type,
div #storyBody br+.${insertionBlockClass}[hidden] > div:last-of-type {
margin-bottom: ${paragraphLineHeight*2}px;
}
`
styleElement.text(styleText);
jQuery(‘head’).append(styleElement);
}
//
}
}
jQuery(element).insertBefore(this.paragraphEndNodes[index]);
}
else {
console.warn(‘Foundation.ParagraphTool.insertElemenAt: invalid insertion index’, index);
}
}
this.insertElemenAtEnd = function (element) {
if (this.paragraphEndNodes.length) {
let lastNode = this.getNodeAtIndex(this.paragraphEndNodes.length -1);
if (this.isDoubleBrParagraphBreak(lastNode)
|| this.isBrParagraphBreakBeforeBlockElement(lastNode)) {
if (jQuery(element).get(0).tagName.match(/SCRIPT/i) !== null) {
jQuery(‘
‘).insertAfter(this.paragraphEndNodes[index]);
jQuery(‘
‘).insertAfter(this.paragraphEndNodes[index]);
}
else {
jQuery(‘div.fdn-content-body, div #storyBody’).append(”)
let lineHeight = jQuery(‘[line-height-check]’).get(0).clientHeight;
jQuery(‘[line-height-check]’).remove()
if (jQuery(element).prop(‘tagName’).match(/HIDDEN/i) !== null) {
jQuery(element).children(‘div’).last().css({ marginBottom: `${lineHeight*2}px` });
}
else {
jQuery(element).css({
marginTop: `${lineHeight*2}px`,
marginBottom: `${lineHeight}px`
});
}
}
}
}
this.bodyContainer.append(element);
}
this.getNodeAtIndex = function (index) {
return this.paragraphEndNodes[index];
}
}
`);
}
var paragraphCount = myParagraphTool.getParagraphEndNodeCount();
// No need to insert if there aren’t enough paragaphs
if (paragraphCount >= parseInt(item.requiredCountToDisplay)) {
// Matches specific paragraph insertion indexes
if (item.insertPoint.match(/^d+$/) !== null) {
var insertIndex = parseInt(item.insertPoint) – 1;
// Insert within content
if (insertIndex < paragraphCount) {
myParagraphTool.insertElemenAtIndex(componentElement, insertIndex);
}
// Append to the end if the insert point is beyond the paragraph count
else {
myParagraphTool.insertElemenAtEnd(componentElement)
}
}
// Matches for 1/2, 1/4, 2/3, 5/6, etc
else if (item.insertPoint.match(/^[1223456]/[23456]$/) !== null) {
var fractionMatch = new RegExp(/^([123456])(?:/)([23456]$)/);
var fractionPart = parseInt(item.insertPoint.match(fractionMatch)[1]);
var fractionWhole = parseInt(item.insertPoint.match(fractionMatch)[2]);
var fractionValue = fractionPart / fractionWhole;
var fractionIndex = Math.floor(myParagraphTool.paragraphEndNodes.length * fractionValue) – 1;
myParagraphTool.insertElemenAtIndex(componentElement, fractionIndex);
}
// Matches for every Nth insertion point
else if (item.insertPoint.match(/^d*th$/i) !== null) {
var intervalIndex = parseInt(item.insertPoint.match(/^(d*)th$/i)[1]);
var startingIndex = parseInt(item.startingPoint) – 1;
var insertionMax = parseInt(item.maxInsertions) || 100;
var insertionCount = 0;
for (var i = startingIndex; i < myParagraphTool.paragraphEndNodes.length && insertionCount < insertionMax; i++) {
if ((i – startingIndex) % intervalIndex === 0) {
let currentNode = myParagraphTool.getNodeAtIndex(i);
const clonedComponent = componentElement.clone();
myParagraphTool.insertElemenAtIndex(clonedComponent, i);
insertionCount++;
}
}
}
}
});
Foundation.Content[‘20725128’].setupInlineComponents = function () { return true; };
if (typeof callback === ‘function’) {
callback();
}
}, 200);
}
Foundation.Content[‘20725128’].previewInsertionPoints = function () {
var myParagraphTool = Foundation.Content[‘20725128’].paragraphTool
myParagraphTool.paragraphEndNodes.each((index, item) => {
const insertionPointPlaceholder = jQuery(`
`)
myParagraphTool.insertElemenAtIndex(insertionPointPlaceholder, index);
});
return ‘Paragraph insertion placeholders applied.’;
}