Files
bip39/src/js/extend.js
AmagiDDmxh 919acaa0bb redesign & code BIP39 (#1)
* redesign & code BIP39

* optimize the UI after hide private infomation

* toggle button styles in table

* responsive web design & add filter effect when hide private data

* translate into chinese

* transtate update

* modify meta tag

* decrease container's width

* favicon & site title

* page header

* language test

* layout fine-turning

* Add ignores

* Update compile script

* Correct replace styling behavior

* Add deploy shell script

* Move assets to root, change according image src

* update content: form__recovery_phrase__hint

* Remove `.DS_Store`

* Add Google GA script

* Update favicon tag and 'loading' zh translation

* remove tippyjs

* remove tippyjs files

* remove npm package

Co-authored-by: Franco Chen <chenhuifan.gg@gmail.com>
2021-07-06 17:17:25 +08:00

61 lines
1.7 KiB
JavaScript

// Solution: https://css-tricks.com/sticky-smooth-active-nav/
function smoothScroll() {
let mainNavLinks = document.querySelectorAll(".js-anchor-link");
window.addEventListener("scroll", (event) => {
let fromTop = window.scrollY;
mainNavLinks.forEach((link) => {
let section = document.querySelector(link.hash);
if (
section.offsetTop <= fromTop &&
section.offsetTop + section.offsetHeight > fromTop
) {
link.classList.add("anchor-link-active");
} else {
link.classList.remove("anchor-link-active");
}
});
});
}
// Get the trigger of dropdown
const enableDropdown = (btnID, menuID) => {
const dropdownActiveClass = "dropdown__menu--active";
const trigger = document.getElementById(btnID);
// Get content of dropdown
const dropdownMenu = document.getElementById(menuID);
const showDropdown = () => {
dropdownMenu.classList.add(dropdownActiveClass);
};
const hideDropdown = () => {
dropdownMenu.classList.remove(dropdownActiveClass);
};
// Click trigger to show content of dropdown
trigger.addEventListener("click", function () {
if (
dropdownMenu.classList.contains(dropdownActiveClass)
) {
hideDropdown();
} else {
showDropdown();
}
});
// Hide content of dropdown if click outside of dropdown element
document.addEventListener("click", (event) => {
if (event.target.closest(".js-dropdown")) return
hideDropdown();
});
}
smoothScroll();
enableDropdown("recoveryPhrasePopoverBtn", "recoveryPhrasePopoverContent");
enableDropdown("languagePopoverBtn", "languagePopoverContent");
enableDropdown("derivedAddressesPopoverBtn", "derivedAddressesPopoverContent");