/* * actions-partials.js * * Delegated event handlers extracted from inline on* attributes and * href="javascript:" links in templates/partials/*.html, for CSP compliance * (lets script-src drop 'unsafe-inline'). The delegated dispatcher lives in * static/the core module; it looks these up by name as globals and invokes them with * `this` bound to the dispatching element and args from data-arg/data-arg2. * * Each function preserves the original inline behavior verbatim. */ // No-op verb: lets an element use data-stop/data-prevent modifiers without // running any action (former onclick="event.stopPropagation();"). window.noop = function () {}; // link_row.html window.onMoveLink = function (dir) { moveLink(this, parseInt(dir, 10)); }; window.onEditLink = function () { editLink(this); }; window.onSaveLink = function () { saveLink(this); }; window.onCancelLink = function () { cancelLink(this); }; // git_nav.html window.navToValue = function () { if (this.value) window.location.href = this.value; }; // insertion_list.html window.insertionsStartUpload = function () { MNW.insertions.startUpload(); }; window.onInsertionFileSelected = function () { MNW.insertions.handleFileSelected(this); }; window.onInsertionRename = function (id) { MNW.insertions.rename(id, this.dataset.title); }; // promo_codes_list.html and item_license_keys.html (copy to clipboard) window.copyText = function () { navigator.clipboard.writeText(this.dataset.copy); }; // promo_codes_list.html (toggle inline edit row) window.togglePromoEditRow = function () { this.closest('tr').nextElementSibling.classList.toggle('hidden'); }; // tag_suggestions.html window.onAddTagSuggestion = function (id) { addTagById(id); this.remove(); }; // discover_results.html window.onOpenCollectionPicker = function () { openCollectionPicker(this.dataset.itemId, this); }; // item_edit_row.html window.onPriceInput = function () { this.nextElementSibling.value = Math.round(parseFloat(this.value || 0) * 100); }; // placement_list.html window.onPlacementPositionChange = function () { MNW.insertions.toggleOffsetInput(this.value); }; window.onAddPlacement = function (id) { MNW.insertions.addPlacement(id); }; // toast.html window.dismissToast = function () { this.parentElement.remove(); }; // slug_status.html window.applySlugSuggestion = function () { var i = this.closest('.form-group').querySelector('input[name=slug]'); if (i) { i.value = this.dataset.slug; i.dispatchEvent(new Event('keyup', { bubbles: true })); } }; // tip_button.html window.toggleTipForm = function () { this.nextElementSibling.classList.toggle('hidden'); };