diff options
author | Matthieu Aubry <mattab@users.noreply.github.com> | 2016-09-27 06:07:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-27 06:07:56 +0300 |
commit | 5bb324fa50e86397817b20d1847b1a277120091f (patch) | |
tree | c3c6914a53d0daea774a1f9c4d96b8fd3b2b7e93 /plugins/Overlay | |
parent | 9a2ef80577e54c2ca839decd2bcada41cb57c660 (diff) |
Tweak Overlay bubbles for better readability
As submitted by @phoob in https://github.com/piwik/piwik/issues/10447#issuecomment-245845463
Diffstat (limited to 'plugins/Overlay')
-rw-r--r-- | plugins/Overlay/client/followingpages.js | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/plugins/Overlay/client/followingpages.js b/plugins/Overlay/client/followingpages.js index 3185b87b67..8d6d1dcfdc 100644 --- a/plugins/Overlay/client/followingpages.js +++ b/plugins/Overlay/client/followingpages.js @@ -15,6 +15,9 @@ var Piwik_Overlay_FollowingPages = (function () { /** Reference to create element function */ var c; + /** Counter for the largest clickRate on the page */ + var maxClickRate = 0; + /** Load the following pages */ function load(callback) { // normalize current location @@ -63,7 +66,9 @@ var Piwik_Overlay_FollowingPages = (function () { totalClicks += followingPages[i].referrals; } for (i = 0; i < followingPages.length; i++) { - followingPages[i].clickRate = followingPages[i].referrals / totalClicks * 100; + var clickRate = followingPages[i].referrals / totalClicks * 100; + followingPages[i].clickRate = clickRate; + if (clickRate > maxClickRate) maxClickRate = clickRate; } } @@ -167,8 +172,6 @@ var Piwik_Overlay_FollowingPages = (function () { if( rate < 0.001 ) { rate = '<0.001'; - } else if (rate < 1) { - rate = Math.round( rate * 1000 ) / 1000; } else if (rate < 10) { rate = Math.round(rate * 10) / 10; } else { @@ -177,6 +180,9 @@ var Piwik_Overlay_FollowingPages = (function () { var span = c('span').html(rate + '%'); var tagElement = c('div', 'LinkTag').append(span).hide(); + + tagElement.attr({'data-rateofmax': Math.round(100 * rate/maxClickRate)/100}); + body.prepend(tagElement); linkTag.add(tagElement).hover(function () { @@ -251,17 +257,22 @@ var Piwik_Overlay_FollowingPages = (function () { offset = linkTag.offset(); } + var zoomFactor = 1 + +tagElement.attr('data-rateofmax'); + tagElement.css({'zoom':zoomFactor, 'opacity': zoomFactor/2 }); + offset.top = offset.top / zoomFactor; + offset.left = offset.left / zoomFactor; + top = offset.top - tagHeight + 6; left = offset.left - tagWidth + 10; if (isRight = (left < 2)) { tagElement.addClass('PIS_Right'); - left = offset.left + linkTag.outerWidth() - 10; + left = offset.left + linkTag.outerWidth() / zoomFactor - 10; } if (top < 2) { tagElement.addClass(isRight ? 'PIS_BottomRight' : 'PIS_Bottom'); - top = offset.top + linkTag.outerHeight() - 6; + top = offset.top + linkTag.outerHeight() / zoomFactor - 6; } tagElement.css({ @@ -545,4 +556,4 @@ var Piwik_Overlay_FollowingPages = (function () { }; -})();
\ No newline at end of file +})(); |