Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENT-10267: docs navigation doesn't show user's location #3137

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions generator/_assets/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,12 @@ var buildBreadcrumbs = function (items) {
})
leftMenuBreadcrumbs.innerHTML = html;
var lastItem = items[items.length - 1];
selectedMenu.innerHTML = lastItem.name !== 'Home' ?
'<a href="'+ lastItem.href +'">'+ lastItem.name +' <i class="bi bi-box-arrow-up-right"></i></a>' :
'';
if (window.innerWidth < 1024){
selectedMenu.innerHTML = lastItem.name !== 'Home' ?
'<a href="'+ lastItem.href +'">'+ lastItem.name +' <i class="bi bi-box-arrow-up-right"></i></a>' :
'';
}
}
buildBreadcrumbs(clickedMenuHistory);

document.querySelector('.menu-back').onclick = function () {
if (clickedMenuHistory.length != 1) {
Expand All @@ -249,18 +250,34 @@ document.querySelector('.menu-back').onclick = function () {
var urlPaths = document.location.pathname.split('/');
var url = urlPaths[urlPaths.length - 1]; // get last url part
var currentMenuItem = document.querySelector('.left-menu li[data-url="'+ url +'"]');


if (currentMenuItem != null) {
currentMenuItem.className += ' opened current';
var menuHistory = [];
var currentLink = currentMenuItem.querySelector('a');
// if selected menu item is a parent we show children on mobile menu
if (currentLink && currentMenuItem.classList.contains('parent')){
menuHistory.unshift({href: currentLink.getAttribute('href'), name: currentLink.innerText});
}
var closest = currentMenuItem.closest('ul').closest('li');

if (window.innerWidth > 1023) { // if the window width more than 1023 then treat the menu as desktop one
var closest = currentMenuItem.closest('ul').closest('li');
while (true) {
if (!closest) break;
while (true) {
if (!closest) break;
if (window.innerWidth > 1023) { // if the window width more than 1023 then treat the menu as desktop one
closest.classList.add('opened');
closest = closest.closest('ul').closest('li');
} else {
// Restore history from html
var link = closest.querySelector('a');
if (link){
menuHistory.unshift({href: link.getAttribute('href'), name: link.innerText});
}
}
closest = closest.closest('ul').closest('li');
}
clickedMenuHistory = clickedMenuHistory.concat(menuHistory);
}
buildBreadcrumbs(clickedMenuHistory);

if (window.innerWidth > 1023) {
document.querySelectorAll('.mainMenu li.parent > i').forEach(function (element) {
Expand All @@ -269,6 +286,10 @@ if (window.innerWidth > 1023) {
element.closest('li.parent').classList.toggle('opened');
}
});
} else {
// Small screen
var lastHistoryElement = clickedMenuHistory[clickedMenuHistory.length - 1];
renderNestedMenu(lastHistoryElement.href);
}

function fillVersionWrapperSelect(url) {
Expand Down
Loading