mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-29 11:30:28 -05:00
eee36267d6
Conflicts: - `app/javascript/mastodon/locales/ja.json`: Upstream change too close to a glitch-soc-specific string. The glitch-soc-specific string should not have been in this file, so it has been moved to `app/javascript/flavours/glitch/locales/ja.js`. - `app/javascript/packs/public.js`: Upstream refactored a part, that as usual is split and duplicated in various pack files. Updated those pack files accordingly. - `app/views/layouts/application.html.haml`: Upstream fixed custom.css path in a different way than we did, went with upstream's change.
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
import 'packs/public-path';
|
|
import loadPolyfills from 'flavours/glitch/load_polyfills';
|
|
import ready from 'flavours/glitch/ready';
|
|
import loadKeyboardExtensions from 'flavours/glitch/load_keyboard_extensions';
|
|
import 'cocoon-js-vanilla';
|
|
|
|
function main() {
|
|
const { delegate } = require('@rails/ujs');
|
|
|
|
const toggleSidebar = () => {
|
|
const sidebar = document.querySelector('.sidebar ul');
|
|
const toggleButton = document.querySelector('.sidebar__toggle__icon');
|
|
|
|
if (sidebar.classList.contains('visible')) {
|
|
document.body.style.overflow = null;
|
|
toggleButton.setAttribute('aria-expanded', false);
|
|
} else {
|
|
document.body.style.overflow = 'hidden';
|
|
toggleButton.setAttribute('aria-expanded', true);
|
|
}
|
|
|
|
toggleButton.classList.toggle('active');
|
|
sidebar.classList.toggle('visible');
|
|
};
|
|
|
|
delegate(document, '.sidebar__toggle__icon', 'click', () => {
|
|
toggleSidebar();
|
|
});
|
|
|
|
delegate(document, '.sidebar__toggle__icon', 'keydown', e => {
|
|
if (e.key === ' ' || e.key === 'Enter') {
|
|
e.preventDefault();
|
|
toggleSidebar();
|
|
}
|
|
});
|
|
}
|
|
|
|
loadPolyfills()
|
|
.then(main)
|
|
.then(loadKeyboardExtensions)
|
|
.catch(error => {
|
|
console.error(error);
|
|
});
|