1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-06-27 16:36:00 +00:00

Extract Materialize Sidenav controller

This commit is contained in:
Yassine Guedidi 2025-03-01 00:05:31 +01:00
parent 66c6a25941
commit 1f76184d02
5 changed files with 29 additions and 15 deletions

View file

@ -0,0 +1,24 @@
import { Controller } from '@hotwired/stimulus';
import M from '@materializecss/materialize';
const mobileMaxWidth = 993;
export default class extends Controller {
static values = {
edge: { type: String, default: 'left' },
};
connect() {
this.instance = M.Sidenav.init(this.element, { edge: this.edgeValue });
}
close() {
if (window.innerWidth < mobileMaxWidth) {
this.instance.close();
}
}
disconnect() {
this.instance.destroy();
}
}

View file

@ -39,8 +39,6 @@ import './js/shortcuts/entry';
/* Theme style */
import './scss/index.scss';
const mobileMaxWidth = 993;
/* ==========================================================================
Annotations & Remember position
========================================================================== */
@ -274,11 +272,6 @@ const articleScroll = () => {
};
$(document).ready(() => {
// sidenav
document.querySelectorAll('.sidenav').forEach((element) => {
$(element).sidenav({ edge: element.getAttribute('data-edge') ?? 'left' });
});
$('select').formSelect();
$('.collapsible[data-collapsible="accordion"]').collapsible();
$('.collapsible[data-collapsible="expandable"]').collapsible({
@ -309,9 +302,6 @@ $(document).ready(() => {
$('#nav-btn-add-tag').on('click', () => {
$('.nav-panel-add-tag').toggle();
$('.nav-panel-menu').addClass('hidden');
if (window.innerWidth < mobileMaxWidth) {
$('.sidenav').sidenav('close');
}
$('#tag_label').focus();
return false;
});