{"version":3,"file":"article_page_uk.js","sources":["article_page_uk.js"],"sourcesContent":["(function ($, Drupal) {\n Drupal.behaviors.nppeTttArticleFull = {\n attach: function (context) {\n // ---------\n const $window = $(window);\n const $ct = $(context).find('.node--type-nppe-article');\n const $layoutBuilderLinks = $ct.find('#pel-builder h2, #pel-builder h3');\n // Avoid problems with achors inside the layout builder before use these elements.\n $layoutBuilderLinks.prop('id', 'layoutBuilderId');\n const $progressBarWrapper = $ct.find('.article--progressbar');\n const $articleHero = $ct.find('.article--hero');\n const $progressBar = $ct.find('.progressbar-main-bar');\n const $progressBarAnchors = $ct.find('.article--anchors');\n const $pgDropDownButtonWrapper = $ct.find('.article--dropbtn-wrapper');\n const $pgDropDownButton = $ct.find('.article--dropbtn');\n const $pgDropDownContent = $ct.find('.article--dropdown-content');\n const $pgDropDownItems = $ct.find('.article--dropdown-content li');\n const $pgDropDownLinks = $pgDropDownItems.find('a');\n const $pgSuggestedProducts = $ct.find('.progressbar--suggested-products');\n const $suggestedProductsComponent = $ct.find('.component--products-list');\n const $articleAuthor = $ct.find('.hero--article-author-heading');\n const scrollItems = $pgDropDownLinks.map(function () {\n var item = $($(this).attr('href'));\n if (item.length) {\n return item;\n }\n });\n var mobile = true;\n var paddingOffset = 80;\n var extraOffset = 20;\n var lastId;\n\n $(once('alerts-wrapper', $ct, context)).each(function () {\n // @fixme we are forced to expose $() since DOMElementRelocation\n // does not suport JQuery()\n window.$ = jQuery;\n\n new DOMElementRelocation({\n breakpoints: {\n desk: '(min-width: 1140px)',\n mob: '(min-width: 0px) and (max-width: 1139px)'\n },\n elements: [{\n element: '.field--name-field-article-sidebar-block',\n mob: '.mobile-placeholder--article-sidebar-block',\n desk: false\n }]\n });\n\n // Define the media query.\n $window.mediaQueryEvents({\n breakpoints: {\n 'article_mobile': '(min-width: 0px) and (max-width: 1139px)',\n 'article_desktop': '(min-width: 1140px)'\n }\n });\n\n // Listen mobile breakpoint.\n $window.on('mq.article_mobile', function () {\n mobile = true;\n extraOffset = 20;\n paddingOffset = 80;\n });\n\n // Listen desktop breakpoint.\n $window.on('mq.article_desktop', function () {\n mobile = false;\n extraOffset = 50;\n paddingOffset = 50;\n });\n\n // Make the progress bar sticky and increase/decrease when scroll.\n var progressbarOffset = $progressBarWrapper.offset().top;\n var progressbarHeight = $progressBarWrapper.height();\n\n $window.scroll(function () {\n // eslint-disable-next-line max-len\n var vHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;\n var barWidth = (document.documentElement.scrollTop * 100 / vHeight);\n $progressBar.css('width', barWidth + '%');\n\n if (mobile) {\n if (($window.scrollTop()) > (progressbarOffset + progressbarHeight)) {\n $progressBarWrapper.addClass('sticky');\n $articleHero.css('paddingTop', progressbarHeight + 'px');\n }\n else {\n $progressBarWrapper.removeClass('sticky');\n $articleHero.css('paddingTop', 0);\n }\n }\n });\n\n // Set the dropdown text with the first element.\n $pgDropDownButton.text($pgDropDownItems.eq(0).text());\n $pgDropDownItems.eq(0).addClass('active');\n\n // Dropdown functionality.\n $pgDropDownButtonWrapper.on('click', function () {\n // eslint-disable-next-line max-len\n $pgDropDownContent.add($pgDropDownButtonWrapper).add($pgSuggestedProducts).add($progressBarWrapper).toggleClass('open');\n });\n\n // Close dropdown when the user clicks outside.\n $(document).mouseup(function (e) {\n // If the target of the click isn't the container nor a descendant of the container.\n if ($pgDropDownButtonWrapper.hasClass('open') &&\n\t\t\t\t\t\t!$progressBarAnchors.is(e.target) &&\n\t\t\t\t\t\t$progressBarAnchors.has(e.target).length === 0\n ) {\n // eslint-disable-next-line max-len\n $pgDropDownContent.add($pgDropDownButtonWrapper).add($pgSuggestedProducts).add($progressBarWrapper).removeClass('open');\n }\n });\n\n $pgDropDownItems.on('click', function (e) {\n e.preventDefault();\n\n // Store hash.\n var hash = $(this).find('a')[0].hash;\n\n $('html, body').animate({\n scrollTop: $(hash).offset().top + getOffset()\n }, 100);\n\n $pgDropDownButton.text($(this).text());\n $pgDropDownItems.add($pgDropDownContent.find('li .active')).removeClass('active');\n $(this).addClass('active');\n // eslint-disable-next-line max-len\n $pgDropDownContent.add($pgDropDownButtonWrapper).add($pgSuggestedProducts).add($progressBarWrapper).removeClass('open');\n });\n\n $pgSuggestedProducts.on('click', function () {\n $pgDropDownItems.removeClass('active');\n // eslint-disable-next-line max-len\n $pgDropDownContent.add($pgDropDownButtonWrapper).add($pgSuggestedProducts).add($progressBarWrapper).removeClass('open');\n $pgDropDownButton.text($(this).text());\n\n $('html, body').animate({\n scrollTop: $suggestedProductsComponent.offset().top + getOffset()\n }, 800);\n });\n\n $articleAuthor.on('click', function () {\n $('html, body').animate({\n scrollTop: $('.article-author-bottom').offset().top - ($(window).height() / 2) + ($('.article-author-bottom').outerHeight() / 2)\n }, 500);\n })\n });\n\n // Change dropdown label while scrolling.\n $(window).scroll(function () {\n // Get container scroll position.\n var fromTop = $(this).scrollTop();\n // console.log(fromTop)\n\n // Get id of current scroll item.\n var cur = scrollItems.map(function () {\n if ($(this).offset().top < fromTop - getOffset() + extraOffset) {\n return this;\n }\n });\n\n // console.log(cur)\n\n // Get the id of the current element.\n cur = cur[cur.length - 1];\n var id = cur && cur.length ? cur[0].id : '';\n\n if (id === '') {\n id = lastId;\n }\n\n if (lastId !== id) {\n lastId = id;\n\n // Set/remove letter-active class\n $pgDropDownLinks\n .parent().removeClass('active')\n .end().filter('[href=\\'#' + id + '\\']').parent().addClass('active');\n // Change the dropdown label with the active text.\n $pgDropDownButton.text($pgDropDownLinks.filter('[href=\\'#' + id + '\\']').text());\n }\n });\n\n function getOffset () {\n var offsetValue = 0;\n if (mobile) {\n // Offset of the sticky menu with 45px or 10px of paddings.\n offsetValue = offsetValue - $pgDropDownButtonWrapper.height() - paddingOffset;\n }\n else {\n offsetValue = offsetValue - paddingOffset;\n }\n return offsetValue;\n }\n // ---------\n }\n };\n})(jQuery, Drupal);\n"],"names":["$","Drupal","behaviors","nppeTttArticleFull","attach","context","$window","window","$ct","find","prop","$progressBarWrapper","$articleHero","$progressBar","$progressBarAnchors","$pgDropDownButtonWrapper","$pgDropDownButton","$pgDropDownContent","$pgDropDownItems","$pgDropDownLinks","$pgSuggestedProducts","$suggestedProductsComponent","$articleAuthor","scrollItems","map","item","this","attr","length","lastId","mobile","paddingOffset","extraOffset","getOffset","offsetValue","height","once","each","jQuery","DOMElementRelocation","breakpoints","desk","mob","elements","element","mediaQueryEvents","article_mobile","article_desktop","on","progressbarOffset","offset","top","progressbarHeight","scroll","vHeight","document","documentElement","scrollHeight","clientHeight","barWidth","scrollTop","css","addClass","removeClass","text","eq","add","toggleClass","mouseup","e","hasClass","is","target","has","preventDefault","hash","animate","outerHeight","fromTop","cur","id","parent","end","filter"],"mappings":"CAAWA,IAuMAC,OAtMFC,UAAUC,mBAAqB,CACpCC,OAAQ,SAAUC,GAEhB,IAAMC,EAAUN,EAAEO,MAAM,EACxB,IAAMC,EAAMR,EAAEK,CAAO,EAAEI,KAAK,0BAA0B,EAC1BD,EAAIC,KAAK,kCAAkC,EAEnDC,KAAK,KAAM,iBAAiB,EAChD,IAAMC,EAAsBH,EAAIC,KAAK,uBAAuB,EACtDG,EAAeJ,EAAIC,KAAK,gBAAgB,EACxCI,EAAeL,EAAIC,KAAK,uBAAuB,EAC/CK,EAAsBN,EAAIC,KAAK,mBAAmB,EAClDM,EAA2BP,EAAIC,KAAK,2BAA2B,EAC/DO,EAAoBR,EAAIC,KAAK,mBAAmB,EAChDQ,EAAqBT,EAAIC,KAAK,4BAA4B,EAC1DS,EAAmBV,EAAIC,KAAK,+BAA+B,EAC3DU,EAAmBD,EAAiBT,KAAK,GAAG,EAC5CW,EAAuBZ,EAAIC,KAAK,kCAAkC,EAClEY,EAA8Bb,EAAIC,KAAK,2BAA2B,EAClEa,EAAiBd,EAAIC,KAAK,+BAA+B,EACzDc,EAAcJ,EAAiBK,IAAI,WACvC,IAAIC,EAAOzB,EAAEA,EAAE0B,IAAI,EAAEC,KAAK,MAAM,CAAC,EACjC,GAAIF,EAAKG,OACP,OAAOH,CAEX,CAAC,E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