{"version":3,"sources":["webpack:///./static/js/components/hang-punctuation.js","webpack:///./static/js/components/tables.js"],"names":["HangPunctuation","this","containers","Array","from","document","querySelectorAll","punctuationMarks","'","length","forEach","hangPunc","bind","container","containerChildren","childNodes","i","el","tagName","k","hangIfEligible","text","innerText","textContent","htmlClass","Object","keys","mark","indexOf","classList","add","Tables","tables","setUpResponsiveTables","tableEl","tableArr","headerCells","bodyRows","getHeaderContent","setTableDataAtts","push","children","j","setAttribute","wrapInner","parent","wrapper","wrapperClassName","createElement","appendChild","firstChild"],"mappings":"2QAAMA,E,WACJ,c,4FAAc,SACZC,KAAKC,WAAaC,MAAMC,KAAKC,SAASC,iBAAiB,kBACvDL,KAAKM,iBAAmB,CACtB,IAAU,SACV,IAAU,QACV,IAAU,SACVC,IAAU,QACV,IAAU,QACV,IAAU,SACV,IAAU,SACV,IAAU,SAGRP,KAAKC,WAAWO,OAAS,GAC3BR,KAAKC,WAAWQ,QAAQT,KAAKU,SAASC,KAAKX,O,wDAItCY,GAKP,IAJA,IAAMC,EAAoBD,EAAUE,WAI3BC,EAAI,EAAGA,EAAIF,EAAkBL,OAAQO,GAAK,EAAG,CACpD,IAAMC,EAAKH,EAAkBE,GAE7B,GAAmB,eAAfC,EAAGC,QACL,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAGF,WAAWN,OAAQU,GAAK,EAC7ClB,KAAKmB,eAAeH,EAAGF,WAAWI,SAGpClB,KAAKmB,eAAeH,M,qCAKXA,GAAI,WACXI,EAAOJ,EAAGK,WAAaL,EAAGM,YAC5BC,EAAY,aAEFC,OAAOC,KAAKzB,KAAKM,kBACzBG,SAAQ,SAAAiB,GACe,IAAvBN,EAAKO,QAAQD,KAEE,OAAfV,EAAGC,SACY,OAAfD,EAAGC,SACY,OAAfD,EAAGC,SACY,OAAfD,EAAGC,SACY,OAAfD,EAAGC,UAEHM,GAAa,WAEfP,EAAGY,UAAUC,IAAIN,EAAY,EAAKjB,iBAAiBoB,a,gCAM5C3B,a,kNC3DT+B,E,WACJ,c,4FAAc,SACZ9B,KAAK+B,OAAS3B,SAASC,iBAAiB,mBAEpCL,KAAK+B,OAAOvB,QACdR,KAAKgC,wB,uEAIe,WACtBhC,KAAK+B,OAAOtB,SAAQ,SAAAwB,GAClB,IAAMC,EAAW,GACXC,EAAcF,EAAQ5B,iBAAiB,sBACvC+B,EAAWH,EAAQ5B,iBAAiB,YAEtC8B,EAAY3B,SACd,EAAK6B,iBAAiBH,EAAUC,GAChC,EAAKG,iBAAiBF,EAAUF,IAK9BC,EAAY3B,QAAU,EACxByB,EAAQL,UAAUC,IAAI,gBAIbM,EAAY3B,QAAU,GAC/ByB,EAAQL,UAAUC,IAAI,gBAIxB,IAAK,IAAId,EAAI,EAAGA,EAAIoB,EAAY3B,OAAQO,IACH,KAA/BoB,EAAYpB,GAAGO,aACjBa,EAAYpB,GAAGa,UAAUC,IAAI,iB,uCASpBK,EAAUC,GACzB,IAAK,IAAIpB,EAAI,EAAGA,EAAIoB,EAAY3B,OAAQO,IACtCmB,EAASK,KAAKJ,EAAYpB,GAAGO,e,uCAQhBc,EAAUF,GAGzB,IAFA,IAAIM,EAEKzB,EAAI,EAAGA,EAAIqB,EAAS5B,OAAQO,IAAK,CACxCyB,EAAWJ,EAASrB,GAAGyB,SAEvB,IAAK,IAAIC,EAAI,EAAGA,EAAID,EAAShC,OAAQiC,IACnCD,EAASC,GAAGC,aAAa,UAAWR,EAASO,IAC7CzC,KAAK2C,UAAUH,EAASC,GAAI,OAAQ,oB,gCAchCG,EAAQC,EAASC,GAQzB,IAPuB,iBAAZD,IACTA,EAAUzC,SAAS2C,cAAcF,IAGnCD,EAAOI,YAAYH,GACnBA,EAAQjB,UAAUC,IAAIiB,GAEfF,EAAOK,aAAeJ,GAC3BA,EAAQG,YAAYJ,EAAOK,iB,gCAKlBnB","file":"hang-punctuation.js","sourcesContent":["class HangPunctuation {\n constructor() {\n this.containers = Array.from(document.querySelectorAll('.js-hang-punc'));\n this.punctuationMarks = {\n '\\u201c': 'medium', // “ - ldquo - left smart double quote\n '\\u2018': 'small', // ‘ - lsquo - left smart single quote\n '\\u0022': 'medium', // \" - ldquo - left dumb double quote\n '\\u0027': 'small', // ' - lsquo - left dumb single quote\n '\\u00AB': 'large', // « - laquo - left double angle quote\n '\\u2039': 'medium', // ‹ - lsaquo - left single angle quote\n '\\u201E': 'medium', // „ - bdquo - left smart double low quote\n '\\u201A': 'small', // ‚ - sbquo - left smart single low quote\n };\n\n if (this.containers.length > 0) {\n this.containers.forEach(this.hangPunc.bind(this));\n }\n }\n\n hangPunc(container) {\n const containerChildren = container.childNodes;\n\n // Loop over all direct descendants of the $container\n // If it's a blockquote, loop over its direct descendants\n for (let i = 0; i < containerChildren.length; i += 1) {\n const el = containerChildren[i];\n\n if (el.tagName === 'blockquote') {\n for (let k = 0; k < el.childNodes.length; k += 1) {\n this.hangIfEligible(el.childNodes[k]);\n }\n } else {\n this.hangIfEligible(el);\n }\n }\n }\n\n hangIfEligible(el) {\n const text = el.innerText || el.textContent;\n let htmlClass = 'hang-punc-';\n\n const marks = Object.keys(this.punctuationMarks);\n marks.forEach(mark => {\n if (text.indexOf(mark) === 0) {\n if (\n el.tagName === 'H1' ||\n el.tagName === 'H2' ||\n el.tagName === 'H3' ||\n el.tagName === 'H4' ||\n el.tagName === 'H5'\n ) {\n htmlClass += 'header-';\n }\n el.classList.add(htmlClass + this.punctuationMarks[mark]);\n }\n });\n }\n}\n\nexport default HangPunctuation;\n","class Tables {\n constructor() {\n this.tables = document.querySelectorAll('.wp-block-table');\n\n if (this.tables.length) {\n this.setUpResponsiveTables();\n }\n }\n\n setUpResponsiveTables() {\n this.tables.forEach(tableEl => {\n const tableArr = [];\n const headerCells = tableEl.querySelectorAll('thead th, thead td');\n const bodyRows = tableEl.querySelectorAll('tbody tr');\n\n if (headerCells.length) {\n this.getHeaderContent(tableArr, headerCells);\n this.setTableDataAtts(bodyRows, tableArr);\n }\n\n // If the table has more than 4 headers, add the class 'scroll-table'\n // -- the class will let you scroll the headers on mobile through tablet screens\n if (headerCells.length >= 4) {\n tableEl.classList.add('scroll-table');\n\n // If the table has 3 or less headers, add the class 'narrow-table'\n // -- the class will make the width 100%\n } else if (headerCells.length <= 3) {\n tableEl.classList.add('narrow-table');\n }\n\n // If the table has an empty th, add the class 'th-empty'\n for (let i = 0; i < headerCells.length; i++) {\n if (headerCells[i].textContent === '') {\n headerCells[i].classList.add('th-empty');\n }\n }\n });\n }\n\n /**\n * Loop through given table head cells and pushes text content to given array\n */\n getHeaderContent(tableArr, headerCells) {\n for (let i = 0; i < headerCells.length; i++) {\n tableArr.push(headerCells[i].textContent);\n }\n }\n\n /**\n * Loop through table body to set table head text content and cell wrapper for mobile\n * header styling\n */\n setTableDataAtts(bodyRows, tableArr) {\n let children;\n\n for (let i = 0; i < bodyRows.length; i++) {\n children = bodyRows[i].children;\n\n for (let j = 0; j < children.length; j++) {\n children[j].setAttribute('data-th', tableArr[j]);\n this.wrapInner(children[j], 'span', 'cell-contents');\n }\n }\n }\n\n /**\n * Wraps an HTML element around the content of each parent element\n * recreating jQuery's wrapInner() function\n * @see https://api.jquery.com/wrapInner/\n *\n * @param {Node} parent element that needs to be innerwrapped\n * @param {string} wrapper specifies the type of element that will innerwrap\n * @param {string} wrapperClassName class applied to the innerwrap element\n */\n wrapInner(parent, wrapper, wrapperClassName) {\n if (typeof wrapper === 'string') {\n wrapper = document.createElement(wrapper);\n }\n\n parent.appendChild(wrapper);\n wrapper.classList.add(wrapperClassName);\n\n while (parent.firstChild !== wrapper) {\n wrapper.appendChild(parent.firstChild);\n }\n }\n}\n\nexport default Tables;\n"],"sourceRoot":""}