{"version":3,"sources":["webpack://responsitable/webpack/bootstrap","webpack://responsitable/./node_modules/debounce/index.js","webpack://responsitable/./src/table-to-description-list.js","webpack://responsitable/./src/utilities/number.js","webpack://responsitable/./src/utilities/table.js","webpack://responsitable/./src/index.js","webpack://responsitable/./src/utilities/ready.js","webpack://responsitable/./src/is-good-table.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","debounce","func","wait","immediate","timeout","args","context","timestamp","result","later","last","Date","now","setTimeout","apply","debounced","this","arguments","callNow","clear","clearTimeout","flush","isValidNumber","isNaN","isOverflown","table","parentNode","offsetWidth","fn","config","breakpoint","debounceTime","scrollNote","makeResponsible","tableWrapper","document","createElement","classList","add","replaceChild","appendChild","innerHTML","style","display","querySelectorAll","length","hasCaption","reverse","forEach","prepend","item","querySelector","heads","bodies","head","children","tagName","toLowerCase","headRow","isValid","Array","from","child","body","numHeadings","row","isGoodTable","dlUl","headings","map","cell","term","description","reduce","descriptionList","li","contains","getDescriptionListUlFromTable","determineWhichToShow","window","innerWidth","addEventListener","attachEvent","readyState","configure","Number"],"mappings":"8BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,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D,EAAxBH,KAAwB,EAAlBC,aAGbxB,QAAQ,SAAAE,GAAI,OAAIwB,EAAgBlC,YAAYU,KAEzDwB,GACLvC,SAASC,cAAc,SAE3BiC,IAAI,SAAAK,GAEJ,IAAMC,EAAKxC,SAASC,cAAc,MAIlC,OAFAuC,EAAGnC,YAAYkC,GAERC,IAEPF,OAAO,SAACN,EAAMQ,GAMd,OAHKR,EAAK9B,UAAUuC,SAAS,kBAAkBT,EAAK9B,UAAUC,IAAI,iBAClE6B,EAAK3B,YAAYmC,GAEVR,GACLhC,SAASC,cAAc,OGFdyC,CAA8BpD,GAcrCqD,EAAuB,WACxBC,OAAOC,YAAcnD,EAAOC,YAX5BqC,EAAKzC,YAAYyC,EAAKzC,WAAWa,aAAad,EAAO0C,GAaxDnC,EAAWU,MAAMC,QAAUnB,EAAYC,GAAS,UAAY,SAE5DO,EAAWU,MAAMC,QAAU,OAVxBlB,EAAMC,YAAYD,EAAMC,WAAWa,aAAa4B,EAAM1C,KAiB3DqD,IACAC,OAAOE,iBAAiB,SAAUjF,IAAS8E,EAAsBjD,EAAOE,iBClEzDH,EDqEV,WACUO,SAASS,iBAAiB,uBAClCI,QAAQ,SAAAvB,GAAK,OAAIQ,EAAgBR,OCzEXU,SAAS+C,YAAsC,aAAxB/C,SAASgD,WAAoD,YAAxBhD,SAASgD,YAExDvD,IAAOO,SAAS8C,iBAAiB,mBAAoBrD,GD0EzF,IAAMwD,EAAY,SAAC,GAAiC,IAA/BtD,EAA+B,EAA/BA,WAAYC,EAAmB,EAAnBA,aACnCT,EAAcQ,KAAaD,EAAOC,WAAauD,OAAOvD,IACtDR,EAAcS,KAAeF,EAAOE,aAAesD,OAAOtD","file":"responsitable.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","/**\n * Returns a function, that, as long as it continues to be invoked, will not\n * be triggered. The function will be called after it stops being called for\n * N milliseconds. If `immediate` is passed, trigger the function on the\n * leading edge, instead of the trailing. The function also has a property 'clear' \n * that is a function which will clear the timer to prevent previously scheduled executions. \n *\n * @source underscore.js\n * @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/\n * @param {Function} function to wrap\n * @param {Number} timeout in ms (`100`)\n * @param {Boolean} whether to execute at the beginning (`false`)\n * @api public\n */\nfunction debounce(func, wait, immediate){\n var timeout, args, context, timestamp, result;\n if (null == wait) wait = 100;\n\n function later() {\n var last = Date.now() - timestamp;\n\n if (last < wait && last >= 0) {\n timeout = setTimeout(later, wait - last);\n } else {\n timeout = null;\n if (!immediate) {\n result = func.apply(context, args);\n context = args = null;\n }\n }\n };\n\n var debounced = function(){\n context = this;\n args = arguments;\n timestamp = Date.now();\n var callNow = immediate && !timeout;\n if (!timeout) timeout = setTimeout(later, wait);\n if (callNow) {\n result = func.apply(context, args);\n context = args = null;\n }\n\n return result;\n };\n\n debounced.clear = function() {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n };\n \n debounced.flush = function() {\n if (timeout) {\n result = func.apply(context, args);\n context = args = null;\n \n clearTimeout(timeout);\n timeout = null;\n }\n };\n\n return debounced;\n};\n\n// Adds compatibility for ES modules\ndebounce.debounce = debounce;\n\nmodule.exports = debounce;\n","export const getDescriptionListUlFromTable = table => {\n\tconst headings = table.querySelectorAll('thead th');\n\n\t// We're going to return an unordered list of description lists, but first we\n\t// begin by creating an array from all rows in the table's body\n\treturn [...table.querySelectorAll('tbody tr')]\n\t\t.map(row => {\n\t\t\t// We map each of those rows to a description list, but begin by starting\n\t\t\t// with an array created from all of the cells in that row\n\t\t\treturn [...row.querySelectorAll('td')]\n\t\t\t\t.map((cell, i) => {\n\t\t\t\t\t// Which we map to an object containing a dt (term) and dd\n\t\t\t\t\t// (description) for each cell\n\t\t\t\t\tconst term = document.createElement('dt');\n\t\t\t\t\tconst description = document.createElement('dd');\n\t\t\t\t\tterm.innerHTML = headings[i].innerHTML;\n\t\t\t\t\tdescription.innerHTML = cell.innerHTML;\n\n\t\t\t\t\treturn { term, description };\n\t\t\t\t})\n\t\t\t\t.reduce((descriptionList, { term, description }) => {\n\t\t\t\t\t// We then reduce the array of paired dts and dls to a single\n\t\t\t\t\t// description list containing all of those terms and descriptions\n\t\t\t\t\t[term, description].forEach(item => descriptionList.appendChild(item));\n\n\t\t\t\t\treturn descriptionList;\n\t\t\t\t}, document.createElement('dl'));\n\t\t})\n\t\t.map(descriptionList => {\n\t\t\t// Now that we have an array of description lists, we create an li\n\t\t\tconst li = document.createElement('li');\n\t\t\t// Shove the description list inside\n\t\t\tli.appendChild(descriptionList);\n\t\t\t// And return it\n\t\t\treturn li;\n\t\t})\n\t\t.reduce((dlUl, li) => {\n\t\t\t// Now we simply reduce an array of list items into a single ul containing\n\t\t\t// said list items\n\t\t\tif (!dlUl.classList.contains('responsitable')) dlUl.classList.add('responsitable');\n\t\t\tdlUl.appendChild(li);\n\n\t\t\treturn dlUl;\n\t\t}, document.createElement('ul'));\n};\n","export const isValidNumber = n => n && !isNaN(n);\n","export const hasCaption = table => table.querySelectorAll('caption').length > 0;\n\nexport const isOverflown = table => table.parentNode && table.offsetWidth > table.parentNode.offsetWidth;\n","import debounce from 'debounce';\nimport ready from '~/utilities/ready';\nimport '~/style';\nimport { isGoodTable } from '~/is-good-table';\nimport { getDescriptionListUlFromTable } from '~/table-to-description-list';\nimport { isValidNumber } from '~/utilities/number';\nimport { hasCaption, isOverflown } from '~/utilities/table';\n\nconst config = {\n\tbreakpoint: 639,\n\tdebounceTime: 200,\n\tscrollNote: '(Scroll right for more)'\n};\n\nconst makeResponsible = table => {\n\t// Wrap the table in a responsive div first\n\tconst tableWrapper = document.createElement('div');\n\ttableWrapper.classList.add('responsitable-wrapper');\n\ttable.parentNode.replaceChild(tableWrapper, table);\n\ttableWrapper.appendChild(table);\n\n\t// Set up our \"scroll for more\" note\n\tconst scrollNote = document.createElement('em');\n\tscrollNote.classList.add('responsitable-scroll-note');\n\tscrollNote.innerHTML = config.scrollNote;\n\tif (!isOverflown(table)) scrollNote.style.display = 'none';\n\tif (hasCaption(table)) {\n\t\t[document.createElement('br'), scrollNote].forEach(item => {\n\t\t\ttable.querySelector('caption').appendChild(item);\n\t\t});\n\t} else {\n\t\t[document.createElement('br'), scrollNote].reverse().forEach(() => {\n\t\t\ttableWrapper.prepend(scrollNote);\n\t\t});\n\t}\n\n\t// We only want to continue if the table is formatted the way we expect it to\n\t// be.\n\tif (!isGoodTable(table)) return;\n\n\t// Get our description list\n\tconst dlUl = getDescriptionListUlFromTable(table);\n\n\t// Function to display the table\n\tconst displayTable = () => {\n\t\tif (dlUl.parentNode) dlUl.parentNode.replaceChild(table, dlUl);\n\t};\n\n\t// Function to display the description lists\n\tconst displayDescriptionLists = () => {\n\t\tif (table.parentNode) table.parentNode.replaceChild(dlUl, table);\n\t};\n\n\t// Function that determines which of the two should be shown, and then shows\n\t// it.\n\tconst determineWhichToShow = () => {\n\t\tif (window.innerWidth >= config.breakpoint) {\n\t\t\tdisplayTable();\n\t\t\tscrollNote.style.display = isOverflown(table) ? 'initial' : 'none';\n\t\t} else {\n\t\t\tscrollNote.style.display = 'none';\n\t\t\tdisplayDescriptionLists();\n\t\t}\n\t};\n\n\t// Finally, make sure we're showing the correct one at page load and configure\n\t// our resize event listener to show the correct item upon resize.\n\tdetermineWhichToShow();\n\twindow.addEventListener('resize', debounce(determineWhichToShow, config.debounceTime));\n};\n\nready(() => {\n\tconst tables = document.querySelectorAll('table.responsitable');\n\ttables.forEach(table => makeResponsible(table));\n});\n\nexport const configure = ({ breakpoint, debounceTime }) => {\n\tif (isValidNumber(breakpoint)) config.breakpoint = Number(breakpoint);\n\tif (isValidNumber(debounceTime)) config.debounceTime = Number(debounceTime);\n};\n","const documentIsReady = () => document.attachEvent ? document.readyState === 'complete' : document.readyState !== 'loading';\n\nexport default (fn) => documentIsReady() ? fn() : document.addEventListener('DOMContentLoaded', fn);\n","export const isGoodTable = table => {\n\t// Does table only have one head?\n\tconst heads = table.querySelectorAll('thead');\n\tif (heads.length !== 1) return false;\n\n\t// Does table only have one body?\n\tconst bodies = table.querySelectorAll('tbody');\n\tif (bodies.length !== 1) return false;\n\n\t// Does head only have one row?\n\tconst head = heads[0];\n\tif (head.children.length !== 1) return false;\n\tif (head.children[0].tagName.toLowerCase() !== 'tr') return false;\n\n\t// Does head row only contain th elements?\n\tconst headRow = head.children[0];\n\tlet isValid = true;\n\tArray.from(headRow.children).forEach(child => {\n\t\tif (child.tagName.toLowerCase() !== 'th') isValid = false;\n\t});\n\tif (!isValid) return false;\n\n\t// Now let's check the body\n\tconst body = bodies[0];\n\tconst numHeadings = headRow.children.length;\n\tArray.from(body.children).forEach(row => {\n\t\t// Does body only have tr elements?\n\t\tif (row.tagName.toLowerCase() !== 'tr') isValid = false;\n\t\tif (!isValid) return;\n\n\t\t// Does row have same number of cells as headings?\n\t\tif (row.children.length !== numHeadings) isValid = false;\n\t\tif (!isValid) return;\n\n\t\t// Does row only contain td elements?\n\t\tArray.from(row.children).forEach(child => {\n\t\t\tif (child.tagName.toLowerCase() !== 'td') isValid = false;\n\t\t\tif (!isValid) return;\n\t\t});\n\t});\n\n\treturn isValid;\n};\n"],"sourceRoot":""}