1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-12 08:29:29 +00:00

Fix web site menu button

A bit of Javascript was used to remove the hamburger icon when a
page doesn't have a #sidenav.  This worked when sidenav-incl was
being loaded with jQuery load(), because that mechanism works
asynchronously, and #sidenav was part of the DOM before it ran.
Once we started merging HTML fragments directly into the pages, the
script got called before #sidenav was defined, so the icon was
always being removed.

One solution would be to move the script to footer-incl.html, to
follow the preferred practice of placing scripts at the bottom of
the <body>.  The better solution was to move the "no-sidenav" class
from #main to <body>, so that all components can see it.  This lets
us use CSS rules to hide the icon.
This commit is contained in:
Andy McFadden 2021-06-08 13:56:29 -07:00
parent 537668883c
commit 7c5a0dfdb8
20 changed files with 11 additions and 100 deletions

View File

@ -19,7 +19,7 @@
<title>6502bench Tools</title>
</head>
<body>
<body class="no-sidenav">
<div id="masthead">
<!-- START: /masthead-incl.html -->
@ -41,11 +41,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state
@ -58,7 +53,7 @@
<!-- END: /topnav-incl.html -->
</div>
<div id="main" class="no-sidenav">
<div id="main">
<p>6502bench is a code development "workbench" for the 65xx family
of processors, including the 6502, 65C02, and 65802/65816. It currently

View File

@ -103,14 +103,20 @@ kbd.key {
background-color: #5f5f5f;
}
/* inline-block seems to help keep the text and icon consistent when
expanding and collapsing (vs. inline) */
/*
* Show nothing but HOME initially. Expand the set as the screen widens.
* inline-block seems to help keep the text and icon consistent when
* expanding and collapsing (vs. inline).
*/
#topnav a {display:inline-block;}
#topnav a:not(:first-child) {display:none;}
#topnav a.icon {
float: right;
display: block;
}
.no-sidenav #topnav a.icon {
display: none; /* no sidenav, no icon */
}
#topnav button {
float: right;
display: block;
@ -300,7 +306,7 @@ kbd.key {
/* make room for sidenav */
margin-left: 188px;
}
#main.no-sidenav {
.no-sidenav #main {
/* ...or not */
margin-left: 8px;
}

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -34,11 +34,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state

View File

@ -7,11 +7,6 @@
</a>
</nav>
<script>
// If page has no sidenav, don't show the sidenav toggle button.
if (document.getElementById("sidenav") == undefined) {
$("#topnav-menuicon").hide();
}
// Sidenav toggle function.
//
// Use a jQuery function to toggle the sidenav bar. The initial state