Polish download action buttons in Classic and Glass Stage

This commit is contained in:
Jonathan Sykes
2026-10-04 02:48:08 +08:00
parent 2042c9b6fc
commit 04b620e3c7
8 changed files with 89 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
/* Downloads page UI module. Grouped jobs, storage info, confirmed cancellation. */
(function (root) {
'use strict';
const actionButtons = typeof module !== 'undefined' ? require('./download-actions.js') : root.DownloadActions;
const errors = typeof module !== 'undefined' ? require('./download-errors.js') : root.DownloadErrors;
const bytes = n => {
@@ -222,10 +223,7 @@
acts.className = 'dl-actions';
if (isActive) {
const pauseBtn = doc.createElement('button');
pauseBtn.type = 'button';
pauseBtn.className = 'dl-act';
pauseBtn.textContent = 'Pause';
const pauseBtn = actionButtons.create(doc, 'pause', job.title || job.id);
pauseBtn.setAttribute('aria-label', `Pause ${job.title || job.id}`);
pauseBtn.onclick = (e) => {
e.stopPropagation();
@@ -234,10 +232,7 @@
};
acts.appendChild(pauseBtn);
} else if (isPaused) {
const resumeBtn = doc.createElement('button');
resumeBtn.type = 'button';
resumeBtn.className = 'dl-act';
resumeBtn.textContent = 'Resume';
const resumeBtn = actionButtons.create(doc, 'resume', job.title || job.id);
resumeBtn.setAttribute('aria-label', `Resume ${job.title || job.id}`);
resumeBtn.onclick = (e) => {
e.stopPropagation();
@@ -246,10 +241,7 @@
};
acts.appendChild(resumeBtn);
} else if (isFailed) {
const retryBtn = doc.createElement('button');
retryBtn.type = 'button';
retryBtn.className = 'dl-act';
retryBtn.textContent = 'Retry';
const retryBtn = actionButtons.create(doc, 'retry', job.title || job.id);
retryBtn.setAttribute('aria-label', `Retry ${job.title || job.id}`);
retryBtn.onclick = (e) => {
e.stopPropagation();
@@ -259,10 +251,7 @@
acts.appendChild(retryBtn);
}
const cancelBtn = doc.createElement('button');
cancelBtn.type = 'button';
cancelBtn.className = 'dl-act danger';
cancelBtn.textContent = 'Cancel';
const cancelBtn = actionButtons.create(doc, 'cancel', job.title || job.id);
cancelBtn.setAttribute('aria-label', `Cancel ${job.title || job.id}`);
cancelBtn.onclick = (e) => {
e.stopPropagation();