diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-10-10 10:47:42 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-10-10 10:47:42 +0300 |
commit | 67f4408d741b62e61f1fd767b4724727c489b42c (patch) | |
tree | 7e7eb50c2797ad968bb238472036d6b2d39c4555 /app/assets/javascripts/header.js | |
parent | d6170ce4d8a0cbfd8552531c29163e44549222cf (diff) |
Fix bad type checking to prevent 0 count badge to be shown
Diffstat (limited to 'app/assets/javascripts/header.js')
-rw-r--r-- | app/assets/javascripts/header.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/app/assets/javascripts/header.js b/app/assets/javascripts/header.js index dc170c60456..ea2e2205077 100644 --- a/app/assets/javascripts/header.js +++ b/app/assets/javascripts/header.js @@ -1,7 +1,16 @@ -/* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, no-var */ +import { highCountTrim } from '~/lib/utils/text_utility'; -$(document).on('todo:toggle', function(e, count) { - var $todoPendingCount = $('.todos-count'); - $todoPendingCount.text(gl.text.highCountTrim(count)); - $todoPendingCount.toggleClass('hidden', count === 0); +/** + * Updates todo counter when todos are toggled. + * When count is 0, we hide the badge. + * + * @param {jQuery.Event} e + * @param {String} count + */ +$(document).on('todo:toggle', (e, count) => { + const parsedCount = parseInt(count, 10); + const $todoPendingCount = $('.todos-count'); + + $todoPendingCount.text(highCountTrim(parsedCount)); + $todoPendingCount.toggleClass('hidden', parsedCount === 0); }); |