-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Showing
2 changed files
with
15 additions
and
31 deletions.
There are no files selected for viewing
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
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,42 +1,26 @@ | ||
/** | ||
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> | ||
* @copyright (C) 2024 Open Source Matters, Inc. <https://www.joomla.org> | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
/** | ||
* Every quickicon with an ajax request url loads data and set them into the counter element | ||
* Also the data name is set as singular or plural. | ||
* A SR-only text is added | ||
* The class pulse gets 'warning', 'success' or 'error', depending on the retrieved data. | ||
*/ | ||
if (!Joomla) { | ||
throw new Error('Joomla API was not properly initialized'); | ||
} | ||
|
||
const initModUser = () => { | ||
const buttons = [].slice.call(document.querySelectorAll('.mod_user-colorScheme')); | ||
|
||
console.log(window.document); | ||
const buttons = document.querySelectorAll('.mod_user-colorScheme'); | ||
|
||
buttons.forEach(button => { | ||
button.addEventListener('click', e => { | ||
e.preventDefault(); | ||
buttons.forEach((button) => { | ||
button.addEventListener('click', (e) => { | ||
e.preventDefault(); | ||
|
||
const docEl = document.documentElement | ||
const colorScheme = docEl.dataset.colorScheme; | ||
const docEl = document.documentElement; | ||
const { colorScheme } = docEl.dataset; | ||
const newScheme = colorScheme !== 'dark' ? 'dark' : 'light'; | ||
|
||
const newScheme = colorScheme !== 'dark' ? 'dark' : 'light'; | ||
docEl.dataset.colorScheme = newScheme; | ||
docEl.dataset.bsTheme = newScheme; | ||
|
||
docEl.dataset.colorScheme = newScheme; | ||
docEl.dataset.bsTheme = newScheme; | ||
|
||
const expires = new Date(); | ||
expires.setTime(expires.getTime() + 31536000000); | ||
document.cookie = `colorScheme=${newScheme}; expires=${expires.toUTCString()};`; | ||
document.dispatchEvent(new CustomEvent('joomla:color-scheme-change', { bubbles: true })); | ||
|
||
}); | ||
document.cookie = `colorScheme=${newScheme};`; | ||
document.dispatchEvent(new CustomEvent('joomla:color-scheme-change', { bubbles: true })); | ||
}); | ||
|
||
}); | ||
}; | ||
|
||
document.addEventListener('DOMContentLoaded', initModUser); | ||
initModUser(); |