From: Stas Vilchik Date: Tue, 15 Sep 2015 14:45:39 +0000 (+0200) Subject: SONAR-6852 Improve display of package names inside word cloud widget X-Git-Tag: 5.2-RC1~385 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cf8127c1b33fd0c066b0ec3ad9c970865fd1ffec;p=sonarqube.git SONAR-6852 Improve display of package names inside word cloud widget --- diff --git a/server/sonar-web/src/main/js/libs/widgets/word-cloud.js b/server/sonar-web/src/main/js/libs/widgets/word-cloud.js index c12e02390e4..15fd7e9e96e 100644 --- a/server/sonar-web/src/main/js/libs/widgets/word-cloud.js +++ b/server/sonar-web/src/main/js/libs/widgets/word-cloud.js @@ -13,12 +13,21 @@ WordCloud.prototype.sizeLow = 10; + WordCloud.prototype.formatDirectory = function (path) { + var dirs = path.split('/'); + if (dirs.length > 2) { + return '.../' + dirs[dirs.length - 1]; + } else { + return path; + } + }; + WordCloud.prototype.renderWords = function () { var that = this; var words = this.wordContainer.selectAll('.cloud-word').data(this.components()), wordsEnter = words.enter().append('a').classed('cloud-word', true); wordsEnter.text(function (d) { - return d.name; + return d.qualifier === 'DIR' ? that.formatDirectory(d.name) : d.name; }); wordsEnter.attr('href', function (d) { return that.options().baseUrl + '?id=' + encodeURIComponent(d.key);