const _fileExtensionIconMapping = new Map<string, string>(
Object.entries({
// archive
- zip: "archive",
- rar: "archive",
- tar: "archive",
- gz: "archive",
+ zip: "zipper",
+ rar: "zipper",
+ tar: "zipper",
+ gz: "zipper",
// audio
mp3: "audio",
pptx: "powerpoint",
// text
- txt: "text",
+ txt: "lines",
// word
doc: "word",
return Core.extend(super._getParameters() as object, parameters as object) as ArbitraryObject;
}
- protected _replaceFileIcon(fileIcon: HTMLElement, media: Media, size: number): void {
+ protected _replaceFileIcon(fileIcon: FaIcon, media: Media, size: number): void {
if (media.elementTag) {
fileIcon.outerHTML = media.elementTag;
} else if (media.tinyThumbnailType) {
DomUtil.replaceElement(fileIcon, img);
} else {
- fileIcon.classList.remove("fa-spinner");
-
let fileIconName = FileUtil.getIconNameByFilename(media.filename);
if (fileIconName) {
- fileIconName = "-" + fileIconName;
+ fileIconName = `file-${fileIconName}`;
+ } else {
+ fileIconName = "file";
}
- fileIcon.classList.add(`fa-file${fileIconName}-o`);
+
+ fileIcon.setIcon(fileIconName, false);
}
}
file.querySelector(".columnMediaID")!.textContent = media.mediaID.toString();
// update icon
- this._replaceFileIcon(file.querySelector(".fa-spinner") as HTMLSpanElement, media, 48);
+ this._replaceFileIcon(file.querySelector("fa-icon")!, media, 48);
} else {
let error: MediaUploadError = data.returnValues.errors[internalFileId];
if (!error) {
};
}
- const fileIcon = file.querySelector(".fa-spinner") as HTMLSpanElement;
- fileIcon.classList.remove("fa-spinner");
- fileIcon.classList.add("fa-remove", "pointer", "jsTooltip");
- fileIcon.title = Language.get("wcf.global.button.delete");
- fileIcon.addEventListener("click", (event) => {
- const target = event.currentTarget as HTMLSpanElement;
- target.closest(".mediaFile")!.remove();
+ const deleteButton = document.createElement("button");
+ deleteButton.classList.add("jsTooltip");
+ deleteButton.title = Language.get("wcf.global.button.delete");
+ deleteButton.addEventListener("click", () => {
+ deleteButton.closest(".mediaFile")!.remove();
EventHandler.fire("com.woltlab.wcf.media.upload", "removedErroneousUploadRow");
});
+ const fileIcon = file.querySelector("fa-icon")!;
+ fileIcon.setIcon("xmark", true);
+ fileIcon.insertAdjacentElement("beforebegin", deleteButton);
+ deleteButton.append(fileIcon);
+
file.classList.add("uploadFailed");
const p = file.querySelectorAll(".columnFilename .box48 > div > p")[1] as HTMLElement;
DomTraverse.childByTag(DomTraverse.childByClass(file, "mediaInformation")!, "PROGRESS")!.remove();
if (media) {
- const fileIcon = DomTraverse.childByTag(DomTraverse.childByClass(file, "mediaThumbnail")!, "SPAN")!;
+ const fileIcon = DomTraverse.childByTag(DomTraverse.childByClass(file, "mediaThumbnail")!, "FA-ICON")!;
this._replaceFileIcon(fileIcon, media, 144);
file.classList.add("jsClipboardObject", "mediaFile", "jsObjectActionObject");
};
}
- const fileIcon = DomTraverse.childByTag(DomTraverse.childByClass(file, "mediaThumbnail")!, "SPAN")!;
- fileIcon.classList.remove("fa-spinner");
- fileIcon.classList.add("fa-remove", "pointer");
+ const fileIcon = DomTraverse.childByTag(DomTraverse.childByClass(file, "mediaThumbnail")!, "FA-ICON")!;
+ fileIcon.setIcon("xmark", true);
- file.classList.add("uploadFailed", "jsTooltip");
+ file.classList.add("uploadFailed", "pointer", "jsTooltip");
file.title = Language.get("wcf.global.button.delete");
file.addEventListener("click", () => file.remove());
const progress = element.querySelector("progress") as HTMLProgressElement;
- const icon = document.createElement("span");
- icon.className = "icon icon64 fa-spinner";
+ const icon = document.createElement("fa-icon");
+ icon.size = 64;
+ icon.setIcon("spinner", false);
const fileName = element.textContent;
element.textContent = "";
const small = fileElement.querySelector("small") as HTMLElement;
small.innerHTML = "";
- const icon = fileElement.querySelector(".icon") as HTMLElement;
- icon.classList.remove("fa-spinner");
- icon.classList.add("fa-ban");
+ const icon = fileElement.querySelector("fa-icon")!;
+ icon.setIcon("ban", true);
const innerError = document.createElement("span");
innerError.className = "innerError";
} else {
fileElement.dataset.uniqueFileId = fileData.uniqueFileId;
fileElement.querySelector("small")!.textContent = fileData.filesize.toString();
- const icon = fileElement.querySelector(".icon") as HTMLElement;
+ const icon = fileElement.querySelector("fa-icon")!;
if (fileData.image !== null) {
const a = document.createElement("a");
a.appendChild(image);
icon.replaceWith(a);
} else {
- icon.classList.remove("fa-spinner");
- icon.classList.add(`fa-${fileData.icon}`);
+ icon.setIcon(fileData.icon, fileData.icon === "paperclip");
}
}
} else if (data.error[index] !== undefined) {
const small = fileElement.querySelector("small") as HTMLElement;
small.innerHTML = "";
- const icon = fileElement.querySelector(".icon") as HTMLElement;
- icon.classList.remove("fa-spinner");
- icon.classList.add("fa-ban");
+ const icon = fileElement.querySelector("fa-icon")!;
+ icon.setIcon("ban", true);
let innerError = fileElement.querySelector(".innerError") as HTMLElement;
if (innerError === null) {
StringUtil = tslib_1.__importStar(StringUtil);
const _fileExtensionIconMapping = new Map(Object.entries({
// archive
- zip: "archive",
- rar: "archive",
- tar: "archive",
- gz: "archive",
+ zip: "zipper",
+ rar: "zipper",
+ tar: "zipper",
+ gz: "zipper",
// audio
mp3: "audio",
ogg: "audio",
ppt: "powerpoint",
pptx: "powerpoint",
// text
- txt: "text",
+ txt: "lines",
// word
doc: "word",
docx: "word",
DomUtil.replaceElement(fileIcon, img);
}
else {
- fileIcon.classList.remove("fa-spinner");
let fileIconName = FileUtil.getIconNameByFilename(media.filename);
if (fileIconName) {
- fileIconName = "-" + fileIconName;
+ fileIconName = `file-${fileIconName}`;
}
- fileIcon.classList.add(`fa-file${fileIconName}-o`);
+ else {
+ fileIconName = "file";
+ }
+ fileIcon.setIcon(fileIconName, false);
}
}
_success(uploadId, data) {
});
file.querySelector(".columnMediaID").textContent = media.mediaID.toString();
// update icon
- this._replaceFileIcon(file.querySelector(".fa-spinner"), media, 48);
+ this._replaceFileIcon(file.querySelector("fa-icon"), media, 48);
}
else {
let error = data.returnValues.errors[internalFileId];
filename: file.dataset.filename,
};
}
- const fileIcon = file.querySelector(".fa-spinner");
- fileIcon.classList.remove("fa-spinner");
- fileIcon.classList.add("fa-remove", "pointer", "jsTooltip");
- fileIcon.title = Language.get("wcf.global.button.delete");
- fileIcon.addEventListener("click", (event) => {
- const target = event.currentTarget;
- target.closest(".mediaFile").remove();
+ const deleteButton = document.createElement("button");
+ deleteButton.classList.add("jsTooltip");
+ deleteButton.title = Language.get("wcf.global.button.delete");
+ deleteButton.addEventListener("click", () => {
+ deleteButton.closest(".mediaFile").remove();
EventHandler.fire("com.woltlab.wcf.media.upload", "removedErroneousUploadRow");
});
+ const fileIcon = file.querySelector("fa-icon");
+ fileIcon.setIcon("xmark", true);
+ fileIcon.insertAdjacentElement("beforebegin", deleteButton);
+ deleteButton.append(fileIcon);
file.classList.add("uploadFailed");
const p = file.querySelectorAll(".columnFilename .box48 > div > p")[1];
DomUtil.innerError(p, Language.get(`wcf.media.upload.error.${error.errorType}`, {
else {
DomTraverse.childByTag(DomTraverse.childByClass(file, "mediaInformation"), "PROGRESS").remove();
if (media) {
- const fileIcon = DomTraverse.childByTag(DomTraverse.childByClass(file, "mediaThumbnail"), "SPAN");
+ const fileIcon = DomTraverse.childByTag(DomTraverse.childByClass(file, "mediaThumbnail"), "FA-ICON");
this._replaceFileIcon(fileIcon, media, 144);
file.classList.add("jsClipboardObject", "mediaFile", "jsObjectActionObject");
file.dataset.objectId = media.mediaID.toString();
filename: file.dataset.filename,
};
}
- const fileIcon = DomTraverse.childByTag(DomTraverse.childByClass(file, "mediaThumbnail"), "SPAN");
- fileIcon.classList.remove("fa-spinner");
- fileIcon.classList.add("fa-remove", "pointer");
- file.classList.add("uploadFailed", "jsTooltip");
+ const fileIcon = DomTraverse.childByTag(DomTraverse.childByClass(file, "mediaThumbnail"), "FA-ICON");
+ fileIcon.setIcon("xmark", true);
+ file.classList.add("uploadFailed", "pointer", "jsTooltip");
file.title = Language.get("wcf.global.button.delete");
file.addEventListener("click", () => file.remove());
const title = DomTraverse.childByClass(DomTraverse.childByClass(file, "mediaInformation"), "mediaTitle");
const element = super._createFileElement(file);
element.classList.add("box64", "uploadedFile");
const progress = element.querySelector("progress");
- const icon = document.createElement("span");
- icon.className = "icon icon64 fa-spinner";
+ const icon = document.createElement("fa-icon");
+ icon.size = 64;
+ icon.setIcon("spinner", false);
const fileName = element.textContent;
element.textContent = "";
element.append(icon);
fileElement.classList.add("uploadFailed");
const small = fileElement.querySelector("small");
small.innerHTML = "";
- const icon = fileElement.querySelector(".icon");
- icon.classList.remove("fa-spinner");
- icon.classList.add("fa-ban");
+ const icon = fileElement.querySelector("fa-icon");
+ icon.setIcon("ban", true);
const innerError = document.createElement("span");
innerError.className = "innerError";
innerError.textContent = Language.get("wcf.upload.error.uploadFailed");
else {
fileElement.dataset.uniqueFileId = fileData.uniqueFileId;
fileElement.querySelector("small").textContent = fileData.filesize.toString();
- const icon = fileElement.querySelector(".icon");
+ const icon = fileElement.querySelector("fa-icon");
if (fileData.image !== null) {
const a = document.createElement("a");
a.classList.add("jsImageViewer");
icon.replaceWith(a);
}
else {
- icon.classList.remove("fa-spinner");
- icon.classList.add(`fa-${fileData.icon}`);
+ icon.setIcon(fileData.icon, fileData.icon === "paperclip");
}
}
}
fileElement.classList.add("uploadFailed");
const small = fileElement.querySelector("small");
small.innerHTML = "";
- const icon = fileElement.querySelector(".icon");
- icon.classList.remove("fa-spinner");
- icon.classList.add("fa-ban");
+ const icon = fileElement.querySelector("fa-icon");
+ icon.setIcon("ban", true);
let innerError = fileElement.querySelector(".innerError");
if (innerError === null) {
innerError = document.createElement("span");
public function getIconName()
{
if ($iconName = FileUtil::getIconNameByFilename($this->filename)) {
- return 'file-' . $iconName . '-o';
+ return 'file-' . $iconName;
}
return 'paperclip';
{
static $mapping = [
// archive
- 'zip' => 'archive',
- 'rar' => 'archive',
- 'tar' => 'archive',
- 'gz' => 'archive',
+ 'zip' => 'zipper',
+ 'rar' => 'zipper',
+ 'tar' => 'zipper',
+ 'gz' => 'zipper',
// audio
'mp3' => 'audio',
'ogg' => 'audio',
'ppt' => 'powerpoint',
'pptx' => 'powerpoint',
// text
- 'txt' => 'text',
+ 'txt' => 'lines',
// word
'doc' => 'word',
'docx' => 'word',