|
| 1 | +import BasicWidget from "../basic_widget.js"; |
| 2 | +import { Modal } from "bootstrap"; |
| 3 | +import utils from "../../services/utils.js"; |
| 4 | +import { t } from "../../services/i18n.js"; |
| 5 | + |
| 6 | +const TPL = /*html*/` |
| 7 | +<div class="cpu-arch-dialog modal mx-auto" tabindex="-1" role="dialog" style="z-index: 2000;"> |
| 8 | + <div class="modal-dialog modal-lg" role="document"> |
| 9 | + <div class="modal-content"> |
| 10 | + <div class="modal-header"> |
| 11 | + <h5 class="modal-title">${t("cpu_arch_warning.title")}</h5> |
| 12 | + <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
| 13 | + </div> |
| 14 | + <div class="modal-body"> |
| 15 | + <p>${utils.isMac() ? t("cpu_arch_warning.message_macos") : t("cpu_arch_warning.message_windows")}</p> |
| 16 | +
|
| 17 | + <p>${t("cpu_arch_warning.recommendation")}</p> |
| 18 | + </div> |
| 19 | + <div class="modal-footer d-flex justify-content-between align-items-center"> |
| 20 | + <button class="download-correct-version-button btn btn-primary btn-lg me-2"> |
| 21 | + <span class="bx bx-download"></span> |
| 22 | + ${t("cpu_arch_warning.download_link")} |
| 23 | + </button> |
| 24 | +
|
| 25 | + <button class="btn btn-secondary" data-bs-dismiss="modal">${t("cpu_arch_warning.continue_anyway")}</button> |
| 26 | + </div> |
| 27 | + </div> |
| 28 | + </div> |
| 29 | +</div>`; |
| 30 | + |
| 31 | +export default class IncorrectCpuArchDialog extends BasicWidget { |
| 32 | + private modal!: Modal; |
| 33 | + private $downloadButton!: JQuery<HTMLElement>; |
| 34 | + |
| 35 | + doRender() { |
| 36 | + this.$widget = $(TPL); |
| 37 | + this.modal = Modal.getOrCreateInstance(this.$widget[0]); |
| 38 | + this.$downloadButton = this.$widget.find(".download-correct-version-button"); |
| 39 | + |
| 40 | + this.$downloadButton.on("click", () => { |
| 41 | + // Open the releases page where users can download the correct version |
| 42 | + if (utils.isElectron()) { |
| 43 | + const { shell } = utils.dynamicRequire("electron"); |
| 44 | + shell.openExternal("https://github.com/TriliumNext/Notes/releases/latest"); |
| 45 | + } else { |
| 46 | + window.open("https://github.com/TriliumNext/Notes/releases/latest", "_blank"); |
| 47 | + } |
| 48 | + }); |
| 49 | + |
| 50 | + // Auto-focus the download button when shown |
| 51 | + this.$widget.on("shown.bs.modal", () => { |
| 52 | + this.$downloadButton.trigger("focus"); |
| 53 | + }); |
| 54 | + } |
| 55 | + |
| 56 | + showCpuArchWarningEvent() { |
| 57 | + this.modal.show(); |
| 58 | + } |
| 59 | +} |
0 commit comments