| 1 |
|
| 2 |
* actions-partials.js |
| 3 |
* |
| 4 |
* Delegated event handlers extracted from inline on* attributes and |
| 5 |
* href="javascript:" links in templates/partials/*.html, for CSP compliance |
| 6 |
* (lets script-src drop 'unsafe-inline'). The delegated dispatcher lives in |
| 7 |
* static/the core module; it looks these up by name as globals and invokes them with |
| 8 |
* `this` bound to the dispatching element and args from data-arg/data-arg2. |
| 9 |
* |
| 10 |
* Each function preserves the original inline behavior verbatim. |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
window.noop = function () {}; |
| 16 |
|
| 17 |
|
| 18 |
window.onMoveLink = function (dir) { moveLink(this, parseInt(dir, 10)); }; |
| 19 |
window.onEditLink = function () { editLink(this); }; |
| 20 |
window.onSaveLink = function () { saveLink(this); }; |
| 21 |
window.onCancelLink = function () { cancelLink(this); }; |
| 22 |
|
| 23 |
|
| 24 |
window.navToValue = function () { if (this.value) window.location.href = this.value; }; |
| 25 |
|
| 26 |
|
| 27 |
window.insertionsStartUpload = function () { MNW.insertions.startUpload(); }; |
| 28 |
window.onInsertionFileSelected = function () { MNW.insertions.handleFileSelected(this); }; |
| 29 |
window.onInsertionRename = function (id) { MNW.insertions.rename(id, this.dataset.title); }; |
| 30 |
|
| 31 |
|
| 32 |
window.copyText = function () { navigator.clipboard.writeText(this.dataset.copy); }; |
| 33 |
|
| 34 |
|
| 35 |
window.togglePromoEditRow = function () { this.closest('tr').nextElementSibling.classList.toggle('hidden'); }; |
| 36 |
|
| 37 |
|
| 38 |
window.onAddTagSuggestion = function (id) { addTagById(id); this.remove(); }; |
| 39 |
|
| 40 |
|
| 41 |
window.onOpenCollectionPicker = function () { openCollectionPicker(this.dataset.itemId, this); }; |
| 42 |
|
| 43 |
|
| 44 |
window.onPriceInput = function () { this.nextElementSibling.value = Math.round(parseFloat(this.value || 0) * 100); }; |
| 45 |
|
| 46 |
|
| 47 |
window.onPlacementPositionChange = function () { MNW.insertions.toggleOffsetInput(this.value); }; |
| 48 |
window.onAddPlacement = function (id) { MNW.insertions.addPlacement(id); }; |
| 49 |
|
| 50 |
|
| 51 |
window.dismissToast = function () { this.parentElement.remove(); }; |
| 52 |
|
| 53 |
|
| 54 |
window.applySlugSuggestion = function () { |
| 55 |
var i = this.closest('.form-group').querySelector('input[name=slug]'); |
| 56 |
if (i) { i.value = this.dataset.slug; i.dispatchEvent(new Event('keyup', { bubbles: true })); } |
| 57 |
}; |
| 58 |
|
| 59 |
|
| 60 |
window.toggleTipForm = function () { this.nextElementSibling.classList.toggle('hidden'); }; |
| 61 |
|