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

Way to add a custom menu button that is an immediate, arbitrary link. #83

Open
dabrahams opened this issue Sep 21, 2021 · 1 comment
Open

Comments

@dabrahams
Copy link

dabrahams commented Sep 21, 2021

I currently have

custom: [
  // ...
  { title: 'Home', icon: '<i class="fa fa-home"></i>', content: '<a href="/">course home</a>' },
]

In my menu config, but that will just display a link in the menu panel, and what I really want is that when the Home icon is clicked, the link is immediately followed. Is there a way to get that to happen?

Thanks!

@dabrahams
Copy link
Author

dabrahams commented Jan 7, 2022

I found a workaround, but it ain't pretty:

      Reveal.addEventListener(
        'menu-ready',
        () => {
            function homeOnClick(e) {
              if (e.nodeType == Node.ELEMENT_NODE) {
                e.setAttribute('onclick', 'location.href = "/";');
              }
            }
            var b = document.getElementById('reveal-menu-home-button');
            homeOnClick(b.parentElement)
            do {
                homeOnClick(b);
                b = b.nextSibling;
            }
            while (b);
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant