diff options
author | Phil Hughes <me@iamphill.com> | 2016-08-03 13:30:36 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-08-19 17:27:18 +0300 |
commit | 696740844b58cc24cd983a1b87acc9f7a6acaad7 (patch) | |
tree | f8a606fb67ba314029a2909b8f5d5b52f23387fc /app/assets/javascripts/labels_select.js | |
parent | 931274baab8357fca15094f7f82fd78f35f70c2c (diff) |
Made logic simpler by moving away from underscorejs
Diffstat (limited to 'app/assets/javascripts/labels_select.js')
-rw-r--r-- | app/assets/javascripts/labels_select.js | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/app/assets/javascripts/labels_select.js b/app/assets/javascripts/labels_select.js index c26d902bac1..5eb9def1982 100644 --- a/app/assets/javascripts/labels_select.js +++ b/app/assets/javascripts/labels_select.js @@ -53,7 +53,7 @@ dataType: 'JSON', data: data }).done(function(data) { - var labelCount, template, labelTooltipTitle; + var labelCount, template, labelTooltipTitle, labelTitles; $loading.fadeOut(); $dropdown.trigger('loaded.gl.dropdown'); $selectbox.hide(); @@ -69,20 +69,16 @@ $sidebarCollapsedValue.text(labelCount); if (data.labels.length) { - labelTooltipTitle = _.chain(data.labels) - .map(function (label, i) { - if (i < 5) { - return label.title; - } - }) - .compact() - .values(); + labelTitles = data.labels.map(function(label) { + return label.title; + }); - if (data.labels.length > 5) { - labelTooltipTitle.push('and ' + (data.labels.length - 5) + ' more'); + if (labelTitles.length > 5) { + labelTitles = labelTitles.slice(0, 5); + labelTitles.push('and ' + (data.labels.length - 5) + ' more'); } - labelTooltipTitle = labelTooltipTitle.join(', '); + labelTooltipTitle = labelTitles.join(', '); } else { labelTooltipTitle = ''; $sidebarLabelTooltip.tooltip('destroy'); |