Skip to main content

max / makenotwork

1.0 KB · 20 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 // Copy the item id to the clipboard and flash feedback on the button. The
9 // revert is core/clipboard.ts's, through the legacy bridge, and its duration is
10 // `Intent::Revert`.
11 window.onCopyItemId = function (id) {
12 window.copyWithFeedback(this, id, 'Copied!');
13 };
14
15 // Custom page reset form: confirm before submitting. data-submit auto-prevents
16 // the native submit, so re-submit programmatically when confirmed.
17 window.confirmResetPage = function () {
18 if (confirm('Reset this page to the platform default? This clears your custom HTML and CSS.')) this.submit();
19 };
20