Published March 16, 2010 at 4:49 p.m.
Burlington’s hotly anticipated burger joint, The Farmhouse Tap & Grill on Bank Street, has hired a head chef. When it opens in May, NECI-grad Phillip Clayton, who’s been sous-chef at or tag and empty text nodes as children
let isPHeader = false;
if (currentNodeIsP && currentNode.childNodes.length >= 3) {
let textNodesHaveText = false;
let brStrongElementCount = 0;
let otherElementCount = 0;
currentNode.childNodes.forEach((item)=> {
if (item.nodeType === Node.TEXT_NODE) {
if (item.nodeValue.trim() !== '') {
textNodesHaveText = true;
}
}
else if (item.nodeType === Node.ELEMENT_NODE) {
if (item.nodeName.match(/^B|STRONG$/i) !== null) {
brStrongElementCount++;
}
else {
otherElementCount++;
}
}
})
if (brStrongElementCount === 1 && textNodesHaveText === false && otherElementCount === 0) {
isPHeader = true;
}
}
let isParagraphBreak = prevNodeIsNotBlock && currentNodeIsP && !isPHeader;
if (isParagraphBreak) {
return true;
}
}
return false;
}
this.isBlockAfterParagraph = function (currentNode) {
if (!currentNode) { return false; }
const prevNode = this.getPreviousNonEmptySibling(currentNode);
if (!prevNode) { return false; }
/* */
const currentNodeIsValidBlock = currentNode.nodeName.match(/^H\d|IMG|DIV|BLOCKQUOTE|hr$/i) !== null;
if (!currentNodeIsValidBlock) { return false; }
const prevNodeIsParagraph = prevNode.nodeName === 'P';
if (prevNodeIsParagraph) { return true; }
const prevNodeIsDoubleBr = this.isDoubleBrParagraphBreak(prevNode);
if (prevNodeIsDoubleBr) { return true; }
return false;
}
//
let myParagraphTool = this
this.paragraphEndNodes = myParagraphTool.bodyContainer.first().contents().filter(function(index, element) {
let isText = this.nodeType === Node.TEXT_NODE;
let isElement = this.nodeType === Node.ELEMENT_NODE;
// Empty text node. Move on
if (isText && this.nodeValue.trim() === '') {
return false;
}
let currentNode = this;
if (myParagraphTool.isParagraphBreak(currentNode)) { return true; }
if (myParagraphTool.isDoubleBrParagraphBreak(currentNode)) { return true; }
if (myParagraphTool.isBrParagraphBreakBeforeBlockElement(currentNode)) { return true; }
if (myParagraphTool.isBlockAfterParagraph(currentNode)) { return true; }
//
return false;
})
this.getParagraphEndNodeCount = function () {
return this.paragraphEndNodes.length;
}
this.insertElemenAtIndex = function (element, index) {
let isValidIndex = index < this.paragraphEndNodes.length;
if (isValidIndex) {
let currentNode = this.getNodeAtIndex(index);
if (this.isDoubleBrParagraphBreak(currentNode)
|| this.isBrParagraphBreakBeforeBlockElement(currentNode)) {
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`
});
}
//
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];
}
}
Comments are closed.
From 2014-2020, Seven Days allowed readers to comment on all stories posted on our website. While we've appreciated the suggestions and insights, right now Seven Days is prioritizing our core mission — producing high-quality, responsible local journalism — over moderating online debates between readers.
To criticize, correct or praise our reporting, please send us a letter to the editor or send us a tip. We’ll check it out and report the results.
Online comments may return when we have better tech tools for managing them. Thanks for reading.