Improve navigator UI and context actions
This commit is contained in:
@@ -29,17 +29,28 @@ Code="f07b"
|
||||
}
|
||||
|
||||
const wrapper = toolsLink.parentElement?.tagName === 'LI' ? toolsLink.parentElement : toolsLink;
|
||||
const item = wrapper.cloneNode(true);
|
||||
const link = item.tagName === 'A' ? item : item.querySelector('a');
|
||||
if (!link) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isListItem = wrapper.tagName === 'LI';
|
||||
const item = isListItem ? document.createElement('li') : document.createElement('a');
|
||||
const link = isListItem ? document.createElement('a') : item;
|
||||
link.className = toolsLink.className || '';
|
||||
link.href = targetHref;
|
||||
link.textContent = targetText;
|
||||
link.setAttribute('data-u-navigator-nav', 'true');
|
||||
link.classList.remove('active', 'selected');
|
||||
item.classList?.remove('active', 'selected');
|
||||
link.classList.remove('active', 'selected', 'on');
|
||||
|
||||
if (isListItem) {
|
||||
item.className = wrapper.className || '';
|
||||
item.classList.remove('active', 'selected', 'on');
|
||||
item.appendChild(link);
|
||||
}
|
||||
|
||||
if (location.pathname === targetHref) {
|
||||
toolsLink.classList.remove('active', 'selected', 'on');
|
||||
wrapper.classList?.remove('active', 'selected', 'on');
|
||||
link.classList.add('active');
|
||||
item.classList?.add('active');
|
||||
}
|
||||
|
||||
wrapper.insertAdjacentElement('afterend', item);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user