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AASC,EACnC,ID6DAnC,EAAeyC,QAAQhD,SAASiD,qBAAqB,QAAQ,GAC/D,G","sources":["webpack://developer.gov.sg/./apps/src/communities/meet-the-team.js","webpack://developer.gov.sg/./apps/src/lib/communities.js"],"sourcesContent":["const { jQuery } = window;\nimport { debounce } from \"../lib/communities\";\n\nconst $ = jQuery;\nif (!jQuery) {\n throw new Error(\n \"Meet-the-team couldn't initialize; please make sure jQuery is loaded!\"\n );\n}\n\n$(document).ready(function () {\n const additionalPadding = window.innerWidth < 768 ? 5 : 20;\n\n function getBioAndTitleDivHeight(el) {\n const bioHeight = $(el).find(\".meet-the-team-content-bio\").height();\n const titleHeight = $(el).find(\".meet-the-team-content-title\").height();\n return bioHeight + titleHeight;\n }\n\n function getNumberOfGridColumnCount() {\n // Get the element by its id\n const grid = document.getElementById(\"meet-the-team-grid\");\n // calc computed style\n const gridComputedStyle = window.getComputedStyle(grid);\n // Get computed property of the number of grid columns\n return {\n // get number of grid rows\n gridRowCount: gridComputedStyle\n .getPropertyValue(\"grid-template-rows\")\n .split(\" \").length,\n // get number of grid columns\n gridColumnCount: gridComputedStyle\n .getPropertyValue(\"grid-template-columns\")\n .split(\" \").length,\n };\n }\n\n function scaleContentPadding() {\n let { gridColumnCount } = getNumberOfGridColumnCount();\n\n // We want to set the card on each row to be the same height as each other\n // For example, if the first card is 100px tall, then the second card should be 100px tall, but if the third card is 200px tall, then the fourth card should be 200px tall\n // Get all the cards\n const cards = document.querySelectorAll(\".meet-the-team-card\");\n // Group the variables(height) into groups based on the gridColumnCount\n const cardHeightGroups = Array.from(cards).reduce(function (r, v, i) {\n if (i % gridColumnCount === 0) r.push([]);\n r[r.length - 1].push(getBioAndTitleDivHeight(v));\n return r;\n }, []);\n\n // Find the maxiumum height of the each group\n const maximumOfEachCardHeightGroups = cardHeightGroups.map(function (\n group\n ) {\n return Math.max.apply(null, group);\n });\n\n // Apply the maximum height of each card of their respective row\n $(\".meet-the-team-card\").each(function (index) {\n $(this)\n .find(\".meet-the-team-content\")\n .css(\n \"height\",\n `${\n maximumOfEachCardHeightGroups[Math.floor(index / gridColumnCount)] +\n additionalPadding\n }px`\n );\n });\n }\n\n // Initialize resize observer object\n let resizeObserver = new ResizeObserver(\n debounce(() => {\n scaleContentPadding();\n }, 100)\n );\n\n // Call the function to set the height of the meet-the-team-content div\n resizeObserver.observe(document.getElementsByTagName(\"body\")[0]);\n});\n","export function debounce(func, wait, immediate) {\n var timeout;\n\n return function executedFunction() {\n var context = this;\n var args = arguments;\n\n var later = function () {\n timeout = null;\n if (!immediate) func.apply(context, args);\n };\n\n var callNow = immediate && !timeout;\n\n clearTimeout(timeout);\n\n timeout = setTimeout(later, wait);\n\n if (callNow) func.apply(context, args);\n };\n}\n\nexport function getEventStatusAndBackgroundColor(startDate, endDate, element) {\n const currentDate = new Date();\n const eventEndDateAndTime = new Date(endDate);\n const eventStartDateAndTime = new Date(startDate);\n\n switch (true) {\n case eventStartDateAndTime > currentDate:\n if (element) element.setAttribute(\"data-event-status\", \"upcoming-event\");\n return { status: \"upcoming\", backgroundColor: \"#0161AF\" };\n\n case eventStartDateAndTime <= currentDate &&\n eventEndDateAndTime >= currentDate:\n if (element) element.setAttribute(\"data-event-status\", \"upcoming-event\");\n return { status: \"now\", backgroundColor: \"#D0021B\" };\n\n case currentDate > eventEndDateAndTime:\n if (element) element.setAttribute(\"data-event-status\", \"past-event\");\n return { status: \"past\", backgroundColor: \"#323232\" };\n }\n}\n\nexport function setEventStatusAndBackgroundColor(\n element,\n status,\n backgroundColor\n) {\n [...element.querySelectorAll(\".event-status\")].forEach(item => {\n item.textContent = status.toUpperCase();\n });\n [...element.querySelectorAll(\".event-status-container\")].forEach(item => {\n item.style.backgroundColor = backgroundColor;\n });\n}\n"],"names":["jQuery","window","$","Error","document","ready","additionalPadding","innerWidth","func","immediate","timeout","resizeObserver","ResizeObserver","grid","gridComputedStyle","gridColumnCount","cards","maximumOfEachCardHeightGroups","getElementById","gridRowCount","getComputedStyle","getPropertyValue","split","length","querySelectorAll","Array","from","reduce","r","v","i","el","push","find","height","map","group","Math","max","apply","each","index","this","css","floor","context","args","arguments","later","callNow","clearTimeout","setTimeout","observe","getElementsByTagName"],"sourceRoot":""}