From: Joshua Rüsweg Date: Mon, 6 Aug 2018 14:40:20 +0000 (+0200) Subject: Improve sorting of reaction types in js X-Git-Tag: 5.2.0_Alpha_1~364^2~101^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2ce1c438e2924e9ea0547694bed5cba42d185041;p=GitHub%2FWoltLab%2FWCF.git Improve sorting of reaction types in js See #2508 --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js index bf322088a8..a599e4221f 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js @@ -305,13 +305,22 @@ define( _getSortedReactionTypes: function() { var sortedReactionTypes = []; + // convert our reaction type object to an array for (var key in REACTION_TYPES) { if (!REACTION_TYPES.hasOwnProperty(key)) continue; - var reactionType = REACTION_TYPES[key]; - - sortedReactionTypes[reactionType.showOrder] = reactionType; + sortedReactionTypes.push(REACTION_TYPES[key]); } + // sort the array + sortedReactionTypes.sort(function (a, b) { + if (a.showOrder > b.showOrder) { + return 1; + } + else { + return -1; + } + }); + return sortedReactionTypes; },