* Add JS tips section to frontend documentation
* Replace document.getElementsByTagName('body') with document.body
* Replace querySelectorAll with faster selecting methods where appropriate
* Replace querySelector with faster selecting methods where appropriate
* Fix typo
* Fix forEach and getElementsByClassName
* Change querySelector* to faster methods in erb files
* Change querySelector* to faster methods in ruby files
* Fix runkit tag
* Various fixes
* Update app/assets/javascripts/initializers/initializeEllipsisMenu.js
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
* Update app/assets/javascripts/utilities/slideSidebar.js
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
* Commenting out flaky spec
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
29 lines
873 B
JavaScript
29 lines
873 B
JavaScript
import { h, render, Fragment } from 'preact';
|
|
import { ListNavigation } from '../shared/components/useListNavigation';
|
|
import { KeyboardShortcuts } from '../shared/components/useKeyboardShortcuts';
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const root = document.getElementById('articles-list');
|
|
|
|
render(
|
|
<Fragment>
|
|
<KeyboardShortcuts
|
|
shortcuts={{
|
|
b: (event) => {
|
|
const article = event.target?.closest('.crayons-story');
|
|
|
|
if (!article) return;
|
|
|
|
article.querySelector('button[id^=article-save-button-]')?.click();
|
|
},
|
|
}}
|
|
/>
|
|
<ListNavigation
|
|
itemSelector=".crayons-story"
|
|
focusableSelector="a.crayons-story__hidden-navigation-link"
|
|
waterfallItemContainerSelector="div.paged-stories,div.substories"
|
|
/>
|
|
</Fragment>,
|
|
root,
|
|
);
|
|
});
|