mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-06-01 00:10:08 +00:00
Extract onclick handlers to standalone code
This allows to introduce a strict Content-Security-Policy. Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
15
php/public/click-handlers.js
Normal file
15
php/public/click-handlers.js
Normal file
@@ -0,0 +1,15 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.querySelectorAll('input[data-confirm]').forEach((element) => {
|
||||
element.addEventListener('click', (event) => {
|
||||
if (!confirm(element.dataset.confirm)) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll('[data-stop-event-propagation="true"]').forEach((element) => {
|
||||
element.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -32,4 +32,7 @@ function setThemeIcon(theme) {
|
||||
setThemeToDOM(getSavedTheme());
|
||||
|
||||
// Apply theme when the page loads
|
||||
document.addEventListener('DOMContentLoaded', () => setThemeIcon(getSavedTheme()));
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
setThemeIcon(getSavedTheme())
|
||||
document.querySelector('button#theme-toggle')?.addEventListener('click', () => toggleTheme());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user