Skip to content
This repository was archived by the owner on Dec 6, 2022. It is now read-only.

Commit aceb76f

Browse files
authored
Make header links collapsible on mobile (#262)
-Add two new functions to imports.js: expandHeader() and collapseHeader() -expandHeader() expands the dropdown that appears on screens <1154px and collapseHeader() collapses the dropdown. -On desktop, hovering on the dropdown will open it and hovering off it will close it. -On mobile, clicking on the dropdown will open it and clicking somewhere else will close it.
1 parent 44ec769 commit aceb76f

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

resources/imports.js

+33-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
var referenceLink = "";
12
function reference(link) {
3+
referenceLink = link;
24
const headerContent = `
35
<a href="${link}" target="_parent">
46
<img src="${link}resources/icon.png" width="64px" height="64px" class="navHomeIcon">
@@ -7,8 +9,7 @@ function reference(link) {
79
<a href="${link}forumhelpers" class="navButton" target="_parent">List Of Forum Helpers</a>
810
<a href="https://scratch.mit.edu/studios/3688309/" class="navButton" target="_blank">Our Scratch Studio</a>
911
<a href="https://theforumhelpers.github.io/QuickReply/" class="navButton" target="_parent">QuickReply</a>
10-
11-
<div class="expandableDropdown">
12+
<div class="expandableDropdown" onmouseover="expandHeader()" onmouseout="collapseHeader()">
1213
<a class="expandableLink" href="${link}forumhelpers">List Of Forum Helpers</a>
1314
<a class="expandableLink" href="https://scratch.mit.edu/studios/3688309/">Our Scratch Studio</a>
1415
<a class="expandableLink" href="https://theforumhelpers.github.io/QuickReply/">QuickReply</a>
@@ -52,3 +53,33 @@ function denyPrivacy() {
5253
localStorage.removeItem("FHacceptedDate");
5354
window.location.href = "https://scratch.mit.edu/studios/3688309/";
5455
}
56+
57+
function expandHeader() {
58+
var headerDropdown = document.getElementsByClassName("expandableDropdown")[0];
59+
headerDropdown.style.backgroundImage = "url('" + referenceLink + "resources/arrow.svg')";
60+
headerDropdown.style.height = "60px";
61+
var headerLinks = document.getElementsByClassName("expandableLink");
62+
for (k = 0; k < headerLinks.length; k++) {
63+
headerLinks[k].style.display = "inline";
64+
}
65+
}
66+
67+
function collapseHeader() {
68+
var headerDropdown = document.getElementsByClassName("expandableDropdown")[0];
69+
headerDropdown.style.backgroundImage = "url('" + referenceLink + "resources/expandable.svg')";
70+
headerDropdown.style.height = "50px";
71+
var headerLinks = document.getElementsByClassName("expandableLink");
72+
for (k = 0; k < headerLinks.length; k++) {
73+
headerLinks[k].style.display = "none";
74+
}
75+
}
76+
77+
window.ontouchstart = function(event) {
78+
clickLocation = event.target.className;
79+
if (clickLocation != "expandableDropdown" && clickLocation != "expandableLink") {
80+
collapseHeader();
81+
}
82+
if (clickLocation == "expandableDropdown") {
83+
expandHeader();
84+
}
85+
}

resources/stylesheet.css

-12
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,6 @@ header {
162162
height: 50px;
163163
box-sizing: border-box;
164164
margin: 0px;
165-
}
166-
167-
.expandableDropdown:hover {
168-
background-image: url("arrow.svg"); /*TODO add an animation for a less abrupt change*/
169-
position: absolute;
170-
right: 0;
171-
top: 0;
172-
height: 60px;
173-
}
174-
175-
.expandableDropdown:hover .expandableLink {
176-
display: inline;
177165
position: relative;
178166
top: 60px;
179167
left: 10px;

0 commit comments

Comments
 (0)