From 141dda57e429d0edaceb595bd709927aed23e6e7 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 20 May 2017 08:25:19 +0200 Subject: [PATCH] Add file-specific icons for media in JavaScript code Close #2276 --- .../js/WoltLabSuite/Core/Media/Manager/Select.js | 11 ++++++++--- .../files/js/WoltLabSuite/Core/Media/Upload.js | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Select.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Select.js index 1f44ff037d..c606df8160 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Select.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Select.js @@ -6,8 +6,8 @@ * @license GNU Lesser General Public License * @module WoltLabSuite/Core/Media/Manager/Select */ -define(['Core', 'Dom/Traverse', 'Dom/Util', 'Language', 'ObjectMap', 'Ui/Dialog', 'WoltLabSuite/Core/Media/Manager/Base'], - function(Core, DomTraverse, DomUtil, Language, ObjectMap, UiDialog, MediaManagerBase) { +define(['Core', 'Dom/Traverse', 'Dom/Util', 'Language', 'ObjectMap', 'Ui/Dialog', 'WoltLabSuite/Core/FileUtil', 'WoltLabSuite/Core/Media/Manager/Base'], + function(Core, DomTraverse, DomUtil, Language, ObjectMap, UiDialog, FileUtil, MediaManagerBase) { "use strict"; if (!COMPILER_TARGET_DEFAULT) { @@ -121,8 +121,13 @@ define(['Core', 'Dom/Traverse', 'Dom/Util', 'Language', 'ObjectMap', 'Ui/Dialog' displayElement.innerHTML = '' + (media.altText && media.altText[LANGUAGE_ID] ? media.altText[LANGUAGE_ID] : '') + ''; } else { + var fileIcon = FileUtil.getIconNameByFilename(media.filename); + if (fileIcon) { + fileIcon = '-' + fileIcon; + } + displayElement.innerHTML = '
' - + '' + + '' + '
' + '

' + media.filename + '

' + '

' + media.formattedFilesize + '

' diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js index e739358690..7781ad0ab6 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js @@ -227,7 +227,12 @@ define( } else { fileIcon.classList.remove('fa-spinner'); - fileIcon.classList.add('fa-file-o'); + + var fileIconName = FileUtil.getIconNameByFilename(media.filename); + if (fileIconName) { + fileIconName = '-' + fileIconName; + } + fileIcon.classList.add('fa-file' + fileIconName + '-o'); } }, -- 2.20.1