-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29d0e85
commit 6fa9e6c
Showing
3 changed files
with
125 additions
and
36 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,89 @@ | ||
/** | ||
* Core Scripts for the HydePHP Frontend | ||
* | ||
* | ||
* @package HydePHP - HydeFront | ||
* @version v1.3.x (HydeFront) | ||
* @author Caen De Silva | ||
*/ | ||
|
||
// Handle the main navigation menu | ||
const mainNavigationLinks = document.getElementById("main-navigation-links"); | ||
const openMainNavigationMenuIcon = document.getElementById("open-main-navigation-menu-icon"); | ||
const closeMainNavigationMenuIcon = document.getElementById("close-main-navigation-menu-icon"); | ||
|
||
let navigationOpen = false; | ||
|
||
var mainNavigationLinks = document.getElementById("main-navigation-links"); | ||
var openMainNavigationMenuIcon = document.getElementById("open-main-navigation-menu-icon"); | ||
var closeMainNavigationMenuIcon = document.getElementById("close-main-navigation-menu-icon"); | ||
var navigationOpen = false; | ||
// Toggle the navigation menu visibility when the menu button is clicked | ||
function toggleNavigation() { | ||
if (navigationOpen) { | ||
hideNavigation(); | ||
} else { | ||
} | ||
else { | ||
showNavigation(); | ||
} | ||
} | ||
|
||
// Show the navigation menu items | ||
function showNavigation() { | ||
mainNavigationLinks.classList.remove("hidden"); | ||
openMainNavigationMenuIcon.style.display = "none"; | ||
closeMainNavigationMenuIcon.style.display = "block"; | ||
|
||
navigationOpen = true; | ||
} | ||
|
||
// Hide the navigation menu items | ||
function hideNavigation() { | ||
mainNavigationLinks.classList.add("hidden"); | ||
openMainNavigationMenuIcon.style.display = "block"; | ||
closeMainNavigationMenuIcon.style.display = "none"; | ||
navigationOpen = false; | ||
} | ||
|
||
// Handle the documentation page sidebar | ||
|
||
var sidebarOpen = screen.width >= 768; | ||
|
||
const sidebar = document.getElementById("documentation-sidebar"); | ||
const backdrop = document.getElementById("sidebar-backdrop"); | ||
|
||
const toggleButtons = document.querySelectorAll(".sidebar-button-wrapper"); | ||
|
||
var sidebar = document.getElementById("documentation-sidebar"); | ||
var backdrop = document.getElementById("sidebar-backdrop"); | ||
var toggleButtons = document.querySelectorAll(".sidebar-button-wrapper"); | ||
function toggleSidebar() { | ||
if (sidebarOpen) { | ||
hideSidebar(); | ||
} else { | ||
} | ||
else { | ||
showSidebar(); | ||
} | ||
} | ||
|
||
function showSidebar() { | ||
sidebar.classList.remove("hidden"); | ||
sidebar.classList.add("flex"); | ||
backdrop.classList.remove("hidden"); | ||
document.getElementById("app").style.overflow = "hidden"; | ||
|
||
toggleButtons.forEach((button) => { | ||
toggleButtons.forEach(function (button) { | ||
button.classList.remove("open"); | ||
button.classList.add("closed"); | ||
}); | ||
|
||
sidebarOpen = true; | ||
} | ||
|
||
function hideSidebar() { | ||
sidebar.classList.add("hidden"); | ||
sidebar.classList.remove("flex"); | ||
backdrop.classList.add("hidden"); | ||
document.getElementById("app").style.overflow = null; | ||
|
||
toggleButtons.forEach((button) => { | ||
toggleButtons.forEach(function (button) { | ||
button.classList.add("open"); | ||
button.classList.remove("closed"); | ||
}); | ||
|
||
sidebarOpen = false; | ||
} | ||
|
||
function toggleTheme() { | ||
if (isSelectedThemeDark()) { | ||
setThemeToLight(); | ||
} else { | ||
} | ||
else { | ||
setThemeToDark(); | ||
} | ||
|
||
function isSelectedThemeDark() { | ||
return localStorage.getItem('color-theme') === 'dark' || !('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches; | ||
} | ||
|
||
function setThemeToDark() { | ||
document.documentElement.classList.add("dark"); | ||
localStorage.setItem('color-theme', 'dark'); | ||
} | ||
|
||
function setThemeToLight() { | ||
document.documentElement.classList.remove("dark"); | ||
localStorage.setItem('color-theme', 'light'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/** | ||
* Core Scripts for the HydePHP Frontend | ||
* | ||
* @package HydePHP - HydeFront | ||
* @version v1.3.x (HydeFront) | ||
* @author Caen De Silva | ||
*/ | ||
|
||
// Handle the main navigation menu | ||
const mainNavigationLinks = document.getElementById("main-navigation-links"); | ||
const openMainNavigationMenuIcon = document.getElementById("open-main-navigation-menu-icon"); | ||
const closeMainNavigationMenuIcon = document.getElementById("close-main-navigation-menu-icon"); | ||
|
||
let navigationOpen = false; | ||
|
||
// Toggle the navigation menu visibility when the menu button is clicked | ||
function toggleNavigation() { | ||
if (navigationOpen) { | ||
hideNavigation(); | ||
} else { | ||
showNavigation(); | ||
} | ||
} | ||
|
||
// Show the navigation menu items | ||
function showNavigation() { | ||
mainNavigationLinks.classList.remove("hidden"); | ||
openMainNavigationMenuIcon.style.display = "none"; | ||
closeMainNavigationMenuIcon.style.display = "block"; | ||
|
||
navigationOpen = true; | ||
} | ||
|
||
// Hide the navigation menu items | ||
function hideNavigation() { | ||
mainNavigationLinks.classList.add("hidden"); | ||
openMainNavigationMenuIcon.style.display = "block"; | ||
closeMainNavigationMenuIcon.style.display = "none"; | ||
navigationOpen = false; | ||
} | ||
|
||
// Handle the documentation page sidebar | ||
|
||
var sidebarOpen = screen.width >= 768; | ||
|
||
const sidebar = document.getElementById("documentation-sidebar"); | ||
const backdrop = document.getElementById("sidebar-backdrop"); | ||
|
||
const toggleButtons = document.querySelectorAll(".sidebar-button-wrapper"); | ||
|
||
function toggleSidebar() { | ||
if (sidebarOpen) { | ||
hideSidebar(); | ||
} else { | ||
showSidebar(); | ||
} | ||
} | ||
|
||
function showSidebar() { | ||
sidebar.classList.remove("hidden"); | ||
sidebar.classList.add("flex"); | ||
backdrop.classList.remove("hidden"); | ||
document.getElementById("app").style.overflow = "hidden"; | ||
|
||
toggleButtons.forEach((button) => { | ||
button.classList.remove("open"); | ||
button.classList.add("closed"); | ||
}); | ||
|
||
sidebarOpen = true; | ||
} | ||
|
||
function hideSidebar() { | ||
sidebar.classList.add("hidden"); | ||
sidebar.classList.remove("flex"); | ||
backdrop.classList.add("hidden"); | ||
document.getElementById("app").style.overflow = null; | ||
|
||
toggleButtons.forEach((button) => { | ||
button.classList.add("open"); | ||
button.classList.remove("closed"); | ||
}); | ||
|
||
sidebarOpen = false; | ||
} | ||
|
||
function toggleTheme() { | ||
if (isSelectedThemeDark()) { | ||
setThemeToLight(); | ||
} else { | ||
setThemeToDark(); | ||
} | ||
|
||
function isSelectedThemeDark() { | ||
return localStorage.getItem('color-theme') === 'dark' || !('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches; | ||
} | ||
|
||
function setThemeToDark() { | ||
document.documentElement.classList.add("dark"); | ||
localStorage.setItem('color-theme', 'dark'); | ||
} | ||
|
||
function setThemeToLight() { | ||
document.documentElement.classList.remove("dark"); | ||
localStorage.setItem('color-theme', 'light'); | ||
} | ||
} |