{"version":3,"sources":["webpack://gli-frontend/../web/themes/custom/gilderlehrman_theme/src/js/gli__iframe-resizer.js"],"names":["$","Drupal","behaviors","iframeResize","attach","context","length","iFrameResize","log","onResized","iframe","topOffset","height","width","type","navOffset","document","querySelector","getBoundingClientRect","bottom","currentScrollPosition","scrollTop","targetScrollPosition","top","scrollTo","behavior","jQuery"],"mappings":"CAKA,SAAEA,EAAGC,GAIHA,EAAOC,UAAUC,aAAe,CAC9BC,OAD8B,SACtBC,GACFL,EAAE,eAAgBK,GAASC,QAsB7BC,aArBe,CACbC,KAAK,EACLC,UAAW,YAAmC,IAAjCC,EAAiC,EAAjCA,OACPC,GADwC,EAAzBC,OAAyB,EAAjBC,MAAiB,EAAVC,KAClB,KACVC,EAAYC,SAASC,cAAc,oBAAoBC,wBAAwBC,OACjFJ,EAAYJ,IACdA,EAAYI,GAGd,IAAMK,EAAwBJ,SAASC,cAAc,QAAQI,UAEvDC,EADoBF,EAAwBV,EAAOQ,wBAAwBK,IAChCZ,EAAY,GACzDS,EAAwBE,GAC1BN,SAASC,cAAc,QAAQO,SAAS,CACtCD,IAAKD,EACLG,SAAU,aAMG,kBA5B7B,CAgCGC,OAAQzB","file":"/js/gli__iframe-resizer.js","sourcesContent":["/**\n * @file\n * GilderLehrman iframe resizer.\n */\n\n(($, Drupal) => {\n /**\n * Alters the height of the iframe to correct aspect ratio.\n */\n Drupal.behaviors.iframeResize = {\n attach (context) {\n if ($('.quiz-iframe', context).length) {\n const config = {\n log: false,\n onResized: ({iframe, height, width, type}) => {\n let topOffset = 165;\n const navOffset = document.querySelector('.page-header-new').getBoundingClientRect().bottom;\n if (navOffset > topOffset) {\n topOffset = navOffset;\n }\n\n const currentScrollPosition = document.querySelector('html').scrollTop;\n const iframeTopPosition = currentScrollPosition + iframe.getBoundingClientRect().top;\n const targetScrollPosition = iframeTopPosition - topOffset - 30;\n if (currentScrollPosition > targetScrollPosition) {\n document.querySelector('html').scrollTo({\n top: targetScrollPosition,\n behavior: 'smooth',\n });\n }\n }\n };\n\n iFrameResize(config, '.quiz-iframe');\n }\n },\n };\n})(jQuery, Drupal);\n"],"sourceRoot":""}