<commit_before>
/**
 * DOM-based Routing.
 *
 * Only fires on body classes that match. If a body class contains a dash,
 * replace the dash with an underscore when adding it to the object below.
 * Based on {@link http://goo.gl/EUTi53} by <NAME>.
 *
 * @since 0.1.0
 */
( function( $ ) {

	/**
	 * Toggles an element attribute value.
	 *
	 * @since 0.5.1
	 *
	 * @param  {Number} index Element index.
	 * @param  {Bool}   val   Current attribute value.
	 * @return {Bool}         The updated attribute value.
	 */
	function toggleAttr( index, val ) {
		return 'true' !== val;
	}

	/**
	 * Define your routes and callbacks here.
	 *
	 * @since 0.1.0
	 *
	 * @type {Object}
	 */
	const routes = {

		// All pages.
		common: {

			init() {

				// Code goes here.
			},

			onReady() {

				// Initialize the placeholder polyfill if needed.
				if ( ( document.placeholderPolyfill || {} ).active ) {
					document.placeholderPolyfill();
				}

				// Make sure the nav menu block exists.
				const $nav = $( '.nav--primary' );

				if ( ! $nav.length ) {
					return;
				}

				// Hide / show the nav menu when the toggle button is clicked.
				const $navMenu      = $nav.find( '.menu' ).first();
				const $toggleButton = $nav.find( '.nav-toggle' ).first();

				if ( $toggleButton.length ) {
					$toggleButton.on( 'click', event => {
						event.preventDefault();

						$toggleButton.toggleClass( 'active' );
						$navMenu.slideToggle();
					} );
				}

				// Toggle sub-menus when the parent menu item is clicked.
				$navMenu.on( 'click', '.menu__item', event => {
					event.stopPropagation();

					const $target  = $( event.target );
					const $subMenu = $target.children( '.sub-menu' );

					if ( $subMenu.length ) {

						let menuBlockHeight = $navMenu.outerHeight();

						if ( 'true' === $target.attr( 'aria-expanded' ) ) {
							menuBlockHeight -= $subMenu.outerHeight();
							$target.attr( 'aria-expanded', 'false' );
						} else {
							$target.attr( 'aria-expanded', 'true' );
							menuBlockHeight += $subMenu.outerHeight();
						}

						$navMenu.css( 'max-height', menuBlockHeight );
					}
				} );

				// Collapsible section groups (e.g. accordions).
				const collapsibles = $( '.section-group.is-collapsible' );
<commit_msg>BLRBT-12: Use `collapsibleNav` function for primary and sidebar navs.<commit_after>
/**
 * DOM-based Routing.
 *
 * Only fires on body classes that match. If a body class contains a dash,
 * replace the dash with an underscore when adding it to the object below.
 * Based on {@link http://goo.gl/EUTi53} by <NAME>.
 *
 * @since 0.1.0
 */
( function( $ ) {

	/**
	 * Toggles an element attribute value.
	 *
	 * @since 0.5.1
	 *
	 * @param  {Number} index Element index.
	 * @param  {Bool}   val   Current attribute value.
	 * @return {Bool}         The updated attribute value.
	 */
	function toggleAttr( index, val ) {
		return 'true' !== val;
	}

	/**
	 * Define your routes and callbacks here.
	 *
	 * @since 0.1.0
	 *
	 * @type {Object}
	 */
	const routes = {

		// All pages.
		common: {

			init() {

				// Code goes here.
			},

			onReady() {

				// Initialize the placeholder polyfill if needed.
				if ( ( document.placeholderPolyfill || {} ).active ) {
					document.placeholderPolyfill();
				}

				// Make the primary nav collapsible if it exists.
				const $navPrimary = $( '.nav--primary' );

				if ( $navPrimary.length ) {
					$navPrimary.collapsibleNav();
				}

				// Make the sidebar nav collapsible if it exists.
				const $navSidebar = $( '.nav--sidebar' );

				if ( $navSidebar.length ) {
					$navSidebar.collapsibleNav();
				}

				// Collapsible section groups (e.g. accordions).
				const collapsibles = $( '.section-group.is-collapsible' );

{'fraction_non_alphanumeric': 0.14962526766595288, 'fraction_numerical': 0.006423982869379015, 'mean_word_length': 2.360611510791367, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7299143', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1176, 'n_words': 339}