Cleanup popup
This commit is contained in:
parent
7bfffd7598
commit
a9f83071dc
@ -11,29 +11,29 @@
|
||||
|
||||
<body>
|
||||
<ul>
|
||||
<li id="regular">
|
||||
<li id="regular" data-action="do-regular">
|
||||
<img srcset="/style/button-regular.png, /style/button-regular@2x.png 2x">
|
||||
<span data-i18n="dta.regular"></span>
|
||||
</li>
|
||||
<li id="turbo">
|
||||
<li id="turbo" data-action="do-turbo">
|
||||
<img srcset="/style/button-turbo.png, /style/button-turbo@2x.png 2x">
|
||||
<span data-i18n="dta.turbo">OneClick!</span>
|
||||
</li>
|
||||
<li class="sep">
|
||||
<hr>
|
||||
</li>
|
||||
<li id="single">
|
||||
<li id="single" data-action="do-ingle">
|
||||
<span class="icon icon-add"></span>
|
||||
<span data-i18n="add-download"></span>
|
||||
</li>
|
||||
<li class="sep">
|
||||
<hr>
|
||||
</li>
|
||||
<li id="manager">
|
||||
<li id="manager" data-action="open-manager">
|
||||
<img srcset="/style/button-manager.png, /style/button-manager@2x.png 2x">
|
||||
<span data-i18n="manager.short"></span>
|
||||
</li>
|
||||
<li id="prefs">
|
||||
<li id="prefs" data-action="open-prefs">
|
||||
<span class="icon icon-settings"></span>
|
||||
<span data-i18n="prefs.short">Preferences</span>
|
||||
</li>
|
||||
|
@ -4,34 +4,23 @@
|
||||
import { localize } from "../lib/i18n";
|
||||
import { runtime } from "../lib/browser";
|
||||
|
||||
const $ = document.querySelector.bind(document);
|
||||
|
||||
|
||||
addEventListener("DOMContentLoaded", () => {
|
||||
localize(document.documentElement);
|
||||
|
||||
$("#regular"). addEventListener("click", () => {
|
||||
runtime.sendMessage("do-regular");
|
||||
close();
|
||||
});
|
||||
|
||||
$("#turbo"). addEventListener("click", () => {
|
||||
runtime.sendMessage("do-turbo");
|
||||
close();
|
||||
});
|
||||
|
||||
$("#single"). addEventListener("click", () => {
|
||||
runtime.sendMessage("do-single");
|
||||
close();
|
||||
});
|
||||
|
||||
$("#manager"). addEventListener("click", () => {
|
||||
runtime.sendMessage("open-manager");
|
||||
close();
|
||||
});
|
||||
|
||||
$("#prefs"). addEventListener("click", () => {
|
||||
runtime.sendMessage("open-prefs");
|
||||
close();
|
||||
document.body.addEventListener("click", e => {
|
||||
let target = e.target as HTMLElement;
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
while (target) {
|
||||
const {action} = target.dataset;
|
||||
if (!action) {
|
||||
target = target.parentElement as HTMLElement;
|
||||
continue;
|
||||
}
|
||||
runtime.sendMessage(action);
|
||||
close();
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user