Skip to content

Make right-side menus onclick. #1096

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions static/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
backdrop.style.display = "block";
}
function menuOnClick(e) {
// The "About", "Releases", and "Rust" menus act as menus on desktop,
// and links on mobile (due to pure-menu-opt-children). On desktop,
// we inhibit navigation events on click so the menu open action can
// take effect. Detect desktop by noticing that the second child
// is hidden.
console.log(this.children[1]);
console.log(window.getComputedStyle(this.children[1]).display);
if (this.children.length > 1 && window.getComputedStyle(this.children[1]).display != 'none') {
return false;
}
if (this.getAttribute("href") != "#") {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion templates/header/package_navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h1 id="crate-title">
{# If there are platforms, show a dropdown with them #}
{%- if platforms -%}
<ul class="pure-menu-list platforms-menu">
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover">
<li class="pure-menu-item pure-menu-has-children">
<a href="#" class="pure-menu-link">Platform</a>
<ul class="pure-menu-children">
{%- for platform in platforms -%}
Expand Down
15 changes: 11 additions & 4 deletions templates/header/topbar_begin.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,29 @@
</a>

<ul class="pure-menu-list pure-menu-right">
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover pure-menu-opt-children">
<li class="pure-menu-item pure-menu-has-children pure-menu-opt-children">
<a href="/about" class="pure-menu-link">
<span title="About">{{ "info-circle" | fas }}</span>
<span class="title">About</span>
</a>

<ul class="pure-menu-children">
{{ macros::menu_link(href="/about", text="About") }}
{{ macros::menu_link(href="/about/badges", text="Badges") }}
{{ macros::menu_link(href="/about/builds", text="Builds") }}
{{ macros::menu_link(href="/about/metadata", text="Metadata") }}
{{ macros::menu_link(href="/about/redirections", text="Shorthand URLs") }}
</ul>
</li>{#

#}<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover pure-menu-opt-children">
#}<li class="pure-menu-item pure-menu-has-children pure-menu-opt-children">
<a href="/releases" class="pure-menu-link">
<span title="Releases">{{ "leaf" | fas }}</span>
<span class="title">Releases</span>
</a>

<ul class="pure-menu-children">
{{ macros::menu_link(href="/releases", text="Recent Releases") }}
{{ macros::menu_link(href="/releases/stars", text="Releases by Stars") }}
{{ macros::menu_link(href="/releases/recent-failures", text="Recent Build Failures") }}
{{ macros::menu_link(href="/releases/failures", text="Build Failures by Stars") }}
Expand All @@ -58,12 +60,18 @@
</li>{#

The Rust dropdown menu
#}<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover pure-menu-opt">
#}<li class="pure-menu-item pure-menu-has-children pure-menu-opt">
<a href="https://www.rust-lang.org/" target="_blank" class="pure-menu-link">
Rust
</a>

<ul class="pure-menu-children">
{{ macros::menu_link(
href="https://www.rust-lang.org/",
text="The Rust Programming Language",
target="_blank"
) }}

{{ macros::menu_link(
href="https://doc.rust-lang.org/book/",
text="The Book",
Expand Down Expand Up @@ -103,4 +111,3 @@
</ul>
</li>
</ul>