{"version":3,"names":["$","window","document","on","e","$nav_block_as_vertical_sidebar","menu","undefined","menuItems","currentItem","currentParent","navIcon","_init","find","parents","addClass","children","attr","_hashHandler","prev","console","log","toggleClass","hash","$menu","$hash","location","removeClass","$current","length","each","i","el","newHash","url","originalEvent","newURL","index","indexOf","substring","sidebar_layout_pattern_handler","sidebar","content","anchorLinkEls","anchorLinks","anchorPoints","element","this","_menuHandler","pointEl","linkEl","pageYOffset","offset","top","map","replace","$match","push","width","click","show","removeAttr","hide","resize","jQuery"],"sources":["../../../source/js/blocks/nav-block.js"],"sourcesContent":["(function ($, window, document) {\n\t//\n\t// ... code out here will run immediately on load\n\t//\n\n\tconst debounce = function (func, delay) {\n\t\tlet timer;\n\t\treturn function () {\n\t\t\t//anonymous function\n\t\t\tconst context = this;\n\t\t\tconst args = arguments;\n\t\t\tclearTimeout(timer);\n\t\t\ttimer = setTimeout(() => {\n\t\t\t\tfunc.apply(context, args);\n\t\t\t}, delay);\n\t\t};\n\t};\n\tconst throttle = (func, limit) => {\n\t\tlet inThrottle;\n\t\treturn function () {\n\t\t\tconst args = arguments;\n\t\t\tconst context = this;\n\t\t\tif (!inThrottle) {\n\t\t\t\tfunc.apply(context, args);\n\t\t\t\tinThrottle = true;\n\t\t\t\tsetTimeout(() => (inThrottle = false), limit);\n\t\t\t}\n\t\t};\n\t};\n\n\tconst returnHashFromURL = function (url) {\n\t\t// check for hash in url\n\t\tvar index = url.indexOf(\"#\");\n\n\t\t// return hash if found\n\t\tif (index !== -1) {\n\t\t\tvar hash = url.substring(index + 1);\n\t\t\treturn hash;\n\t\t}\n\n\t\t// otherwise, oops\n\t\treturn false;\n\t};\n\n\t$(function () {\n\t\t// ! OMG; how stop collapsing the damn nav menu\n\t\t$(\".blocks--wrapper\").on(\"click\", function (e) {\n\t\t\t// e.stopPropagation();\n\t\t});\n\n\t\t//\n\t\t// ... code in here will run after jQuery says document is ready\n\t\t//\n\n\t\tconst $nav_block_as_vertical_sidebar = {\n\t\t\t//\n\t\t\t//\n\t\t\tmenu: undefined,\n\t\t\tmenuItems: undefined,\n\t\t\tcurrentItem: undefined,\n\t\t\tcurrentParent: undefined,\n\t\t\tnavIcon: undefined,\n\n\t\t\t//\n\t\t\t//\n\t\t\t//\n\t\t\t_init: function (menu) {\n\t\t\t\t// hoist!\n\t\t\t\t$nav_block_as_vertical_sidebar.menu = menu;\n\t\t\t\t// hoist!\n\t\t\t\t$nav_block_as_vertical_sidebar.menuItems = $(menu).find(\n\t\t\t\t\t\".wp-block-navigation-item\"\n\t\t\t\t);\n\t\t\t\t// hoist!\n\t\t\t\t$nav_block_as_vertical_sidebar.currentItem =\n\t\t\t\t\t$(menu).find(\"[aria-current]\");\n\t\t\t\t// hoist!\n\t\t\t\t$nav_block_as_vertical_sidebar.currentParent = $(menu)\n\t\t\t\t\t.find(\"[aria-current]\")\n\t\t\t\t\t.parents(\".has-child\");\n\t\t\t\t// hoist!\n\t\t\t\t//\n\t\t\t\t//\n\t\t\t\t// * Add 'is-opened' class to the 'has-child' parent of 'current-menu-item'\n\t\t\t\t$($nav_block_as_vertical_sidebar.currentParent).addClass(\"is-opened\");\n\t\t\t\t//\n\t\t\t\t//\n\t\t\t\t//\n\t\t\t\t//\n\n\t\t\t\t// ? tag current page ancestor because wordpress hurts sometimes\n\t\t\t\t$nav_block_as_vertical_sidebar.currentParent.addClass(\n\t\t\t\t\t\"current-page-ancestor\"\n\t\t\t\t);\n\n\t\t\t\t// ? naturally expand using aria\n\t\t\t\t$nav_block_as_vertical_sidebar.currentParent\n\t\t\t\t\t.children(\"[aria-expanded]\")\n\t\t\t\t\t.attr(\"aria-expanded\", \"true\");\n\n\t\t\t\t$nav_block_as_vertical_sidebar.currentParent;\n\n\t\t\t\t// ?\n\t\t\t\t$nav_block_as_vertical_sidebar._hashHandler();\n\n\t\t\t\t//\n\t\t\t\t//\n\t\t\t\t//\n\t\t\t\t// * Dan working on this part\n\t\t\t\t// * MOBILE STUFF\n\n\t\t\t\t// * Get the navIcon (previous sibling of nav.wp-block-navigation)\n\t\t\t\t$nav_block_as_vertical_sidebar.navIcon = $(\n\t\t\t\t\t$nav_block_as_vertical_sidebar.menu\n\t\t\t\t).prev();\n\n\t\t\t\t// * Upon clicking the nav icon\n\t\t\t\t$nav_block_as_vertical_sidebar.navIcon.on(\"click\", function (e) {\n\t\t\t\t\tconsole.log($nav_block_as_vertical_sidebar.navIcon);\n\n\t\t\t\t\t// * Toggle the previous sibling (p.is-the-sidebar-navicon)\n\t\t\t\t\t$($nav_block_as_vertical_sidebar.menu)\n\t\t\t\t\t\t.prev(\".is-the-sidebar-navicon\")\n\t\t\t\t\t\t.toggleClass(\"mobile-revealed\");\n\t\t\t\t});\n\t\t\t},\n\n\t\t\t//\n\t\t\t//\n\t\t\t//\n\t\t\t//\n\t\t\t_hashHandler: function (hash = undefined) {\n\t\t\t\t//\n\t\t\t\tlet $menu = $nav_block_as_vertical_sidebar.menu;\n\t\t\t\t//\n\t\t\t\tlet $hash = window.location.hash;\n\t\t\t\t//\n\t\t\t\tif (hash) {\n\t\t\t\t\t$hash = hash;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\t// ? remove active from all menu items\n\t\t\t\t$nav_block_as_vertical_sidebar.menuItems\n\t\t\t\t\t.children(\"a\")\n\t\t\t\t\t.removeClass(\"is-active\");\n\t\t\t\t//\n\t\t\t\t// ? add active to this menu item\n\t\t\t\tlet $current = $($menu).find('a[href=\"' + $hash + '\"');\n\t\t\t\t$current.addClass(\"is-active\");\n\n\t\t\t\t// ? handle parents of this menu item\n\t\t\t\tif ($current.parents(\".has-child\").length) {\n\t\t\t\t\tlet $currentParent = $current.parents(\".has-child\");\n\t\t\t\t\t$currentParent\n\t\t\t\t\t\t.children(\".wp-block-navigation-submenu__toggle\")\n\t\t\t\t\t\t.attr(\"aria-expanded\", \"true\");\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\n\t\t//\n\t\t// ? new sidebar instance for each sidebar\n\t\t$(\".is-vertical.wp-block-navigation\").each(function (i, el) {\n\t\t\t//\n\t\t\t//\n\t\t\t$nav_block_as_vertical_sidebar._init(el);\n\n\t\t\t//\n\t\t\t//\n\t\t\t$(window).on(\"hashchange\", function (e) {\n\t\t\t\t//\n\t\t\t\tlet newHash = \"#\" + returnHashFromURL(e.originalEvent.newURL);\n\t\t\t\t//\n\t\t\t\t$nav_block_as_vertical_sidebar._hashHandler(newHash);\n\t\t\t});\n\t\t});\n\n\t\t//\n\t\t//\n\t\t//\n\t\tconst sidebar_layout_pattern_handler = {\n\t\t\tsidebar: undefined,\n\t\t\tcontent: undefined,\n\t\t\tmenu: undefined,\n\t\t\tanchorLinkEls: undefined,\n\t\t\tanchorLinks: undefined,\n\t\t\tanchorPoints: [],\n\n\t\t\t_init: function (element) {\n\t\t\t\t// hoist sidebar element\n\t\t\t\tthis.sidebar = $(element).find(\n\t\t\t\t\t\".wp-block-columns > .wp-block-column.is-the-sidebar\"\n\t\t\t\t);\n\t\t\t\t// hoist sidebar menu element (container including navicon)\n\t\t\t\tthis.menu = $(this.sidebar).find(\".is-the-sidebar-menu\");\n\n\t\t\t\t// hoist content column element\n\t\t\t\tthis.content = $(element).find(\n\t\t\t\t\t\".wp-block-columns > .wp-block-column.is-the-content\"\n\t\t\t\t);\n\n\t\t\t\t// menu handler\n\t\t\t\tif (this.menu.length) {\n\t\t\t\t\tthis._menuHandler();\n\t\t\t\t}\n\n\t\t\t\t// ? spy on scroll and update the jump-links if they are there\n\t\t\t\t// ! this actually just runs and hits too much debounce it and conditional it please\n\t\t\t\t$(window).on(\"scroll load\", function () {\n\t\t\t\t\tfor (\n\t\t\t\t\t\tlet index = 0;\n\t\t\t\t\t\tindex < sidebar_layout_pattern_handler.anchorPoints.length;\n\t\t\t\t\t\tindex++\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst pointEl = sidebar_layout_pattern_handler.anchorPoints[index];\n\t\t\t\t\t\tconst linkEl = sidebar_layout_pattern_handler.anchorLinkEls[index];\n\t\t\t\t\t\tif (window.pageYOffset > $(pointEl).offset().top - 220) {\n\t\t\t\t\t\t\t$(sidebar_layout_pattern_handler.anchorLinkEls).removeClass(\n\t\t\t\t\t\t\t\t\"is-active\"\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t$(linkEl).addClass(\"is-active\");\n\n\t\t\t\t\t\t\t// ? handle parents of this menu item\n\t\t\t\t\t\t\t$current = $(linkEl);\n\n\t\t\t\t\t\t\tif ($current.parents(\".has-child\").length) {\n\t\t\t\t\t\t\t\tlet $allParents =\n\t\t\t\t\t\t\t\t\tsidebar_layout_pattern_handler.menu.find(\".has-child\");\n\t\t\t\t\t\t\t\t$allParents\n\t\t\t\t\t\t\t\t\t.children(\".wp-block-navigation-submenu__toggle\")\n\t\t\t\t\t\t\t\t\t.attr(\"aria-expanded\", \"false\");\n\t\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t\tlet $currentParent = $current.parents(\".has-child\");\n\t\t\t\t\t\t\t\t$currentParent\n\t\t\t\t\t\t\t\t\t.children(\".wp-block-navigation-submenu__toggle\")\n\t\t\t\t\t\t\t\t\t.attr(\"aria-expanded\", \"true\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t//\n\t\t\t},\n\n\t\t\t//\n\t\t\t_menuHandler: function () {\n\t\t\t\t// isolate the menu items for later\n\t\t\t\tlet menuItems = $(this.menu).find(\n\t\t\t\t\t\".wp-block-navigation.is-vertical .wp-block-navigation-link\"\n\t\t\t\t);\n\t\t\t\t// isolate the href values of any anchor links found in the menu\n\t\t\t\tthis.anchorLinkEls = $(this.menu).find('a[href^=\"#\"');\n\t\t\t\tthis.anchorLinks = $(this.menu)\n\t\t\t\t\t.find('a[href^=\"#\"')\n\t\t\t\t\t.map(function () {\n\t\t\t\t\t\treturn $(this).attr(\"href\").replace(\"#\", \"\");\n\t\t\t\t\t});\n\t\t\t\t//\n\t\t\t\t$(this.anchorLinks).each(function (i, element) {\n\t\t\t\t\t// the match if we found it\n\t\t\t\t\tlet $match = $(sidebar_layout_pattern_handler.content).find(\n\t\t\t\t\t\t'[id=\"' + element + '\"]'\n\t\t\t\t\t);\n\t\t\t\t\t// isolate all the matched elements by ID\n\t\t\t\t\tsidebar_layout_pattern_handler.anchorPoints.push($match);\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\n\t\t$(\".patterns--layouts--content-with-sidebar\").each(function (\n\t\t\tindex,\n\t\t\telement\n\t\t) {\n\t\t\tsidebar_layout_pattern_handler._init(element);\n\t\t});\n\n\t\t// * For opening and closing sidebar navigation on mobile\n\t\tif ($(document).width() <= 1024) {\n\t\t\t$(\".is-the-sidebar-group\")\n\t\t\t\t.find(\".is-style-eyebrow\")\n\t\t\t\t.click(function () {\n\t\t\t\t\tif ($(this).attr(\"data-content\") != \"close\") {\n\t\t\t\t\t\t$(this).attr(\"data-content\", \"close\");\n\t\t\t\t\t\t$(\".is-the-sidebar-menu\").show();\n\t\t\t\t\t\t$(\".wp-block-navigation__responsive-container\").show();\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$(this).removeAttr(\"data-content\");\n\t\t\t\t\t\t$(\".is-the-sidebar-menu\").hide();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t// * If a menu item is selected, collapse the menu\n\t\t\t$(\".wp-block-navigation__container\").click(function () {\n\t\t\t\t$(\".is-the-sidebar-menu\").hide();\n\t\t\t\t$(\".is-the-sidebar-group\")\n\t\t\t\t\t.find(\".is-style-eyebrow\")\n\t\t\t\t\t.removeAttr(\"data-content\");\n\t\t\t});\n\t\t}\n\n\t\t// * For making sure resizing also triggers sidebar nav toggle\n\t\t$(window).resize(function () {\n\t\t\tif ($(document).width() > 1024) {\n\t\t\t\t$(\".is-the-sidebar-menu\").show();\n\t\t\t}\n\n\t\t\tif ($(document).width() < 1024) {\n\t\t\t\t// * Reset the menu\n\t\t\t\t$(this).removeAttr(\"data-content\");\n\t\t\t\t$(\".is-the-sidebar-menu\").hide();\n\t\t\t\t//\n\t\t\t\t$(\".is-the-sidebar-group\")\n\t\t\t\t\t.find(\".is-style-eyebrow\")\n\t\t\t\t\t.click(function () {\n\t\t\t\t\t\tif ($(this).attr(\"data-content\") != \"close\") {\n\t\t\t\t\t\t\t$(this).attr(\"data-content\", \"close\");\n\t\t\t\t\t\t\t$(\".is-the-sidebar-menu\").show();\n\t\t\t\t\t\t\t$(\".wp-block-navigation__responsive-container\").show();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t$(this).removeAttr(\"data-content\");\n\t\t\t\t\t\t\t$(\".is-the-sidebar-menu\").hide();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\t//\n\t\t// ? end of $.ready\n\t\t//\n\t});\n})(window.jQuery, window, document);\n"],"mappings":"4FAAA,SAAWA,EAAGC,EAAQC,GA4CrBF,GAAE,WAEDA,EAAE,oBAAoBG,GAAG,SAAS,SAAUC,GAE9C,IAME,MAAMC,EAAiC,CAGtCC,UAAMC,EACNC,eAAWD,EACXE,iBAAaF,EACbG,mBAAeH,EACfI,aAASJ,EAKTK,MAAO,SAAUN,GAEhBD,EAA+BC,KAAOA,EAEtCD,EAA+BG,UAAYR,EAAEM,GAAMO,KAClD,6BAGDR,EAA+BI,YAC9BT,EAAEM,GAAMO,KAAK,kBAEdR,EAA+BK,cAAgBV,EAAEM,GAC/CO,KAAK,kBACLC,QAAQ,cAKVd,EAAEK,EAA+BK,eAAeK,SAAS,aAOzDV,EAA+BK,cAAcK,SAC5C,yBAIDV,EAA+BK,cAC7BM,SAAS,mBACTC,KAAK,gBAAiB,QAKxBZ,EAA+Ba,eAS/Bb,EAA+BM,QAAUX,EACxCK,EAA+BC,MAC9Ba,OAGFd,EAA+BM,QAAQR,GAAG,SAAS,SAAUC,GAC5DgB,QAAQC,IAAIhB,EAA+BM,SAG3CX,EAAEK,EAA+BC,MAC/Ba,KAAK,2BACLG,YAAY,kBACnB,GACA,EAMGJ,aAAc,SAAUK,EA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