diff options
author | Phil Hughes <me@iamphill.com> | 2016-07-13 13:53:27 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-08-19 17:27:18 +0300 |
commit | 931274baab8357fca15094f7f82fd78f35f70c2c (patch) | |
tree | 8b9f1708378e5b4818cdc56eb5dcad1d07a3b426 /app/assets | |
parent | e5840a4d9b6d696f26cd1956c5aace2507f3abf0 (diff) |
Added tooltip to label value in collapsed sidebar
Closes #19398
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/labels_select.js | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/app/assets/javascripts/labels_select.js b/app/assets/javascripts/labels_select.js index 0526430989f..c26d902bac1 100644 --- a/app/assets/javascripts/labels_select.js +++ b/app/assets/javascripts/labels_select.js @@ -4,7 +4,7 @@ var _this; _this = this; $('.js-label-select').each(function(i, dropdown) { - var $block, $colorPreview, $dropdown, $form, $loading, $selectbox, $sidebarCollapsedValue, $value, abilityName, defaultLabel, enableLabelCreateButton, issueURLSplit, issueUpdateURL, labelHTMLTemplate, labelNoneHTMLTemplate, labelUrl, projectId, saveLabelData, selectedLabel, showAny, showNo; + var $block, $colorPreview, $dropdown, $form, $loading, $selectbox, $sidebarCollapsedValue, $value, abilityName, defaultLabel, enableLabelCreateButton, issueURLSplit, issueUpdateURL, labelHTMLTemplate, labelNoneHTMLTemplate, labelUrl, projectId, saveLabelData, selectedLabel, showAny, showNo, $sidebarLabelTooltip; $dropdown = $(dropdown); projectId = $dropdown.data('project-id'); labelUrl = $dropdown.data('labels'); @@ -21,6 +21,7 @@ $block = $selectbox.closest('.block'); $form = $dropdown.closest('form'); $sidebarCollapsedValue = $block.find('.sidebar-collapsed-icon span'); + $sidebarLabelTooltip = $block.find('.js-sidebar-labels-tooltip'); $value = $block.find('.value'); $loading = $block.find('.block-loading').fadeOut(); if (issueUpdateURL != null) { @@ -52,7 +53,7 @@ dataType: 'JSON', data: data }).done(function(data) { - var labelCount, template; + var labelCount, template, labelTooltipTitle; $loading.fadeOut(); $dropdown.trigger('loaded.gl.dropdown'); $selectbox.hide(); @@ -66,6 +67,31 @@ } $value.removeAttr('style').html(template); $sidebarCollapsedValue.text(labelCount); + + if (data.labels.length) { + labelTooltipTitle = _.chain(data.labels) + .map(function (label, i) { + if (i < 5) { + return label.title; + } + }) + .compact() + .values(); + + if (data.labels.length > 5) { + labelTooltipTitle.push('and ' + (data.labels.length - 5) + ' more'); + } + + labelTooltipTitle = labelTooltipTitle.join(', '); + } else { + labelTooltipTitle = ''; + $sidebarLabelTooltip.tooltip('destroy'); + } + + $sidebarLabelTooltip + .attr('title', labelTooltipTitle) + .tooltip('fixTitle'); + $('.has-tooltip', $value).tooltip({ container: 'body' }); |