Skip to main content

max / makenotwork

1.2 KB · 25 lines History Blame Raw
1 // Delegated event handlers extracted from inline on* attributes in the
2 // dashboard, dashboard editor, embed, and wizard templates, moved here for CSP
3 // compliance (so script-src can drop 'unsafe-inline'). The dispatcher in
4 // the core module invokes each of these by name with `this` bound to the dispatching
5 // element and any data-arg/data-arg2 attributes passed as arguments. Bodies
6 // are preserved verbatim from the original inline handlers.
7
8 // Reactivate-account form: schedule a page reload after the HTMX request.
9 window.reactivateReload = function () {
10 setTimeout(function(){ window.location.reload(); }, 500);
11 };
12
13 // Copy the item id to the clipboard and flash feedback on the button. The
14 // revert is core/clipboard.ts's, through the legacy bridge; 1500 is the
15 // duration this button already used.
16 window.onCopyItemId = function (id) {
17 window.copyWithFeedback(this, id, 'Copied!', 1500);
18 };
19
20 // Custom page reset form: confirm before submitting. data-submit auto-prevents
21 // the native submit, so re-submit programmatically when confirmed.
22 window.confirmResetPage = function () {
23 if (confirm('Reset this page to the platform default? This clears your custom HTML and CSS.')) this.submit();
24 };
25