<\/div>",
},{
componentOid: '15166787',
parentWrapperClass: '',
insertPoint: '15',
startingPoint: '1',
requiredCountToDisplay: '13',
componentHtml: "
<\/div>",
}];
Foundation.Content['15877026'].setupInlineComponents = function (callback) {
setTimeout(() => {
let contentBody = jQuery('[fdn-content-multi-item="15877026"] .fdn-content-body, div#storyBody');
// For multiple content scenarios
if (contentBody.length) {
Foundation.Content['15877026'].paragraphTool = new window.Foundation.ParagraphTool(contentBody);
}
// Assume only a single content
else {
contentBody = jQuery('.fdn-content-body, #storyBody');
Foundation.Content['15877026'].paragraphTool = new window.Foundation.ParagraphTool(contentBody);
}
var myParagraphTool = Foundation.Content['15877026'].paragraphTool
Foundation.Content['15877026'].inlineComponents.forEach((item,index) => {
if (item.parentWrapperClass.trim() === '') {
var componentElement = jQuery(item.componentHtml);
}
else {
var componentElement = jQuery(`
${item.componentHtml}
`);
}
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['15877026'].setupInlineComponents = function () { return true; };
if (typeof callback === 'function') {
callback();
}
}, 200);
}
Foundation.Content['15877026'].previewInsertionPoints = function () {
var myParagraphTool = Foundation.Content['15877026'].paragraphTool
myParagraphTool.paragraphEndNodes.each((index, item) => {
const insertionPointPlaceholder = jQuery(`
Insertion point ${index+1}
`)
myParagraphTool.insertElemenAtIndex(insertionPointPlaceholder, index);
});
return 'Paragraph insertion placeholders applied.';
}