No edit summary |
No edit summary |
||
Line 35: | Line 35: | ||
$(document).ready(function() { | $(document).ready(function() { | ||
$(' | function toggleOffCanvas() { | ||
} | $('#offcanvas-menu').toggleClass('offcanvas-right'); | ||
} | |||
$('#offcanvas-close').on('click', | |||
$('#offcanvas-close').on('click', toggleOffCanvas); | |||
$('#offcanvas-toggler').on('click', toggleOffCanvas); | |||
$(document).on('click', function(event) { | $(document).on('click', function(event) { | ||
if (!$(event.target).closest('#offcanvas-menu').length && !$(event.target). | if (!$(event.target).closest('#offcanvas-menu').length && !$(event.target).closest('#offcanvas-toggler').length) { | ||
$('#offcanvas-menu'). | if ($('#offcanvas-menu').hasClass('offcanvas-right')) { | ||
toggleOffCanvas(); | |||
} | |||
} | } | ||
}); | }); | ||
}); | }); |
Revision as of 23:12, 20 October 2023
/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready(function () {
$.get(mw.util.wikiScript('api'), {
action: 'query',
meta: 'userinfo',
format: 'json'
}).done(function (data) {
if (data.query.userinfo.id !== 0) {
var username = data.query.userinfo.name;
var userLink = mw.util.getUrl('User:' + username);
$('#user-info').html('<a href="' + userLink + '" class="text-white">' + username + '</a>');
}
});
});
// Add this JavaScript to your script.js file or within a <script> block in your HTML
document.getElementById('offcanvas-toggler').addEventListener('click', function() {
var sidebar = document.getElementById('offcanvas-menu');
if (sidebar.classList.contains('show')) {
sidebar.classList.remove('show');
} else {
sidebar.classList.add('show');
}
});
function toggleSection(header) {
var submenu = header.nextElementSibling;
if (submenu.style.display === "none" || submenu.style.display === "") {
submenu.style.display = "block";
} else {
submenu.style.display = "none";
}
}
$(document).ready(function() {
function toggleOffCanvas() {
$('#offcanvas-menu').toggleClass('offcanvas-right');
}
$('#offcanvas-close').on('click', toggleOffCanvas);
$('#offcanvas-toggler').on('click', toggleOffCanvas);
$(document).on('click', function(event) {
if (!$(event.target).closest('#offcanvas-menu').length && !$(event.target).closest('#offcanvas-toggler').length) {
if ($('#offcanvas-menu').hasClass('offcanvas-right')) {
toggleOffCanvas();
}
}
});
});
This page was edited 146 days ago on 08/26/2024. What links here