| /** |
| * @license |
| * Copyright 2020 The Go Authors. All rights reserved. |
| * Use of this source code is governed by a BSD-style |
| * license that can be found in the LICENSE file. |
| */ |
| |
| import { AccordionController } from './accordion.js'; |
| |
| /** |
| * Instantiates accordion controller for the left sidebar. |
| */ |
| const accordion = document.querySelector('.js-accordion'); |
| if (accordion) { |
| new AccordionController(accordion); |
| } |
| |
| /** |
| * Event handlers for expanding and collapsing the readme section. |
| */ |
| const readme = document.querySelector('.js-readme'); |
| const readmeExpand = document.querySelectorAll('.js-readmeExpand'); |
| const readmeCollapse = document.querySelector('.js-readmeCollapse'); |
| if (readmeExpand && readmeExpand && readmeCollapse) { |
| readmeExpand.forEach(el => |
| el.addEventListener('click', e => { |
| e.preventDefault(); |
| readme.classList.add('UnitReadme--expanded'); |
| readme.scrollIntoView(); |
| }) |
| ); |
| readmeCollapse.addEventListener('click', e => { |
| e.preventDefault(); |
| readme.classList.remove('UnitReadme--expanded'); |
| readme.scrollIntoView(); |
| }); |
| } |