-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathai2html-resizer.156db1cd.js.map
1 lines (1 loc) · 4.99 KB
/
ai2html-resizer.156db1cd.js.map
1
{"version":3,"sources":["scripts/ai2html-resizer.js"],"names":["resizer","elements","document","querySelectorAll","widthById","forEach","el","parent","parentNode","width","id","getBoundingClientRect","minwidth","getAttribute","maxwidth","style","display","documentElement","classList","contains","add","window","addEventListener","throttle","func","wait","options","timeout","context","args","result","previous","now","Date","getTime","later","leading","apply","throttled","_now","remaining","arguments","clearTimeout","trailing","setTimeout"],"mappings":";AAiGC,aA5FD,SAASA,IACDC,IAAAA,EAAWC,SAASC,iBAAiB,+BACrCC,EAAY,GAElBH,EAASI,QAAQ,SAAAC,GACTC,IAAAA,EAASD,EAAGE,WACZC,EAAQL,EAAUG,EAAOG,KAAOH,EAAOI,wBAAwBF,MAC/DG,EAAWN,EAAGO,aAAa,kBAC3BC,EAAWR,EAAGO,aAAa,kBAEjCT,EAAUG,EAAOG,IAAMD,EAErBH,EAAGS,MAAMC,SADNJ,GAAYH,KAAWK,GAAYL,GAAsB,OAAbK,GAC5B,QAEA,SAMV,SAAY,IAErBZ,SAASe,gBAAgBC,UAAUC,SAAS,uBAChDjB,SAASe,gBAAgBC,UAAUE,IAAI,qBAEvCpB,IACAqB,OAAOC,iBAAiB,SAAUC,EAASvB,EAAS,OAgCtD,SAASuB,EAASC,EAAMC,GAAMC,IACxBC,EAASC,EAASC,EAAMC,EADAJ,EAAU,UAAA,OAAA,QAAA,IAAA,UAAA,GAAA,UAAA,GAAA,GAElCK,EAAW,EAETC,EAAMC,KAAKD,KAAQ,WAAM,OAAA,IAAIC,MAAOC,WAEpCC,EAAQ,WACZJ,GAA+B,IAApBL,EAAQU,QAAoB,EAAIJ,IAC3CL,EAAU,KACVG,EAASN,EAAKa,MAAMT,EAASC,GACxBF,IAASC,EAAUC,EAAO,OAuB1BS,OApBW,WACVC,IAAAA,EAAOP,IACRD,IAAgC,IAApBL,EAAQU,UAAmBL,EAAWQ,GACjDC,IAAAA,EAAYf,GAAQc,EAAOR,GAc1BD,OAbPF,EAAU,KACVC,EAAOY,UACHD,GAAa,GAAKA,EAAYf,GAC5BE,IACFe,aAAaf,GACbA,EAAU,MAEZI,EAAWQ,EACXT,EAASN,EAAKa,MAAMT,EAASC,GACxBF,IAASC,EAAUC,EAAO,OACrBF,IAAgC,IAArBD,EAAQiB,WAC7BhB,EAAUiB,WAAWT,EAAOK,IAEvBV,GAIV,OAAA,eAAA,QAAA,aAAA,CAAA,OAAA,IAAA,QAAA,QAAA","file":"ai2html-resizer.156db1cd.js","sourceRoot":"../src","sourcesContent":["/**\n * Resizer script to toggle multiple artboards for responsiveness. Adapted from:\n * https://github.com/newsdev/ai2html/blob/gh-pages/_includes/resizer-script.html\n */\n\nfunction resizer() {\n const elements = document.querySelectorAll('.g-artboard[data-min-width]');\n const widthById = {};\n\n elements.forEach(el => {\n const parent = el.parentNode;\n const width = widthById[parent.id] || parent.getBoundingClientRect().width;\n const minwidth = el.getAttribute('data-min-width');\n const maxwidth = el.getAttribute('data-max-width');\n\n widthById[parent.id] = width;\n if (+minwidth <= width && (+maxwidth >= width || maxwidth === null)) {\n el.style.display = 'block';\n } else {\n el.style.display = 'none';\n }\n });\n}\n\n// Export ai2html resizer initialization to page.js\nexport default function () {\n // only want one resizer on the page\n if (document.documentElement.classList.contains('g-resizer-v3-init')) return;\n document.documentElement.classList.add('g-resizer-v3-init');\n\n resizer();\n window.addEventListener('resize', throttle(resizer, 200));\n}\n\n/**\n * Throttle function adapted from underscore.js.\n *\n * Copyright (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative\n * Reporters & Editors\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n * Terms\n */\n\nfunction throttle(func, wait, options = {}) {\n let timeout, context, args, result;\n let previous = 0;\n\n const now = Date.now || (() => new Date().getTime());\n\n const later = function () {\n previous = options.leading === false ? 0 : now();\n timeout = null;\n result = func.apply(context, args);\n if (!timeout) context = args = null;\n };\n\n const throttled = function () {\n const _now = now();\n if (!previous && options.leading === false) previous = _now;\n const remaining = wait - (_now - previous);\n context = this;\n args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = _now;\n result = func.apply(context, args);\n if (!timeout) context = args = null;\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining);\n }\n return result;\n };\n\n return throttled;\n}\n"]}