()
| 43 | * @param {HTMLElement} $footer |
| 44 | */ |
| 45 | export default function init() { |
| 46 | const { $footer, $toggler, $input } = quickTools; |
| 47 | |
| 48 | $toggler.addEventListener("click", (e) => { |
| 49 | e.preventDefault(); |
| 50 | e.stopPropagation(); |
| 51 | if (appSettings.value.vibrateOnTap) { |
| 52 | navigator.vibrate(config.VIBRATION_TIME); |
| 53 | } |
| 54 | actions("toggle"); |
| 55 | }); |
| 56 | |
| 57 | key.on("shift", (value) => { |
| 58 | if (value) $footer.setAttribute("data-shift", "true"); |
| 59 | else $footer.removeAttribute("data-shift"); |
| 60 | }); |
| 61 | |
| 62 | key.on("ctrl", (value) => { |
| 63 | if (value) $footer.setAttribute("data-ctrl", "true"); |
| 64 | else $footer.removeAttribute("data-ctrl"); |
| 65 | }); |
| 66 | |
| 67 | key.on("alt", (value) => { |
| 68 | if (value) $footer.setAttribute("data-alt", "true"); |
| 69 | else $footer.removeAttribute("data-alt"); |
| 70 | }); |
| 71 | |
| 72 | key.on("meta", (value) => { |
| 73 | if (value) $footer.setAttribute("data-meta", "true"); |
| 74 | else $footer.removeAttribute("data-meta"); |
| 75 | }); |
| 76 | |
| 77 | editorManager.on( |
| 78 | [ |
| 79 | "file-content-changed", |
| 80 | "switch-file", |
| 81 | "new-file", |
| 82 | "file-loaded", |
| 83 | "remove-file", |
| 84 | ], |
| 85 | scheduleUpdateQuickToolsState, |
| 86 | ); |
| 87 | |
| 88 | editorManager.on("save-file", () => { |
| 89 | scheduleUpdateQuickToolsState(); |
| 90 | }); |
| 91 | |
| 92 | editorManager.on("editor-state-changed", updateHistoryButtons); |
| 93 | |
| 94 | appSettings.on("update:quicktoolsItems:after", () => { |
| 95 | setTimeout(updateHistoryButtons, 100); |
| 96 | }); |
| 97 | |
| 98 | root.append($footer); |
| 99 | if (appSettings.value.floatingButton) { |
| 100 | root.appendOuter($toggler); |
| 101 | } |
| 102 | document.body.append($input); |
nothing calls this directly
no test coverage detected