From 23c0ddca39610719f651875fc47e7564394df6b5 Mon Sep 17 00:00:00 2001 From: Stefano Sala Date: Sat, 29 Nov 2014 11:46:43 +0100 Subject: [PATCH] [Toolbar] Handle info position via javascript Place info div to not float out of the window --- .../Resources/views/Profiler/toolbar.css.twig | 4 ---- .../views/Profiler/toolbar_js.html.twig | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig index af82d0853b..90160974b3 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -139,10 +139,6 @@ border-radius: 4px 4px 0 0; } -.sf-toolbarreset > div:last-of-type .sf-toolbar-info { - right: -1px; -} - .sf-toolbar-block .sf-toolbar-info:empty { visibility: hidden; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig index 7082c765d7..dc1e6a71ef 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig @@ -31,6 +31,26 @@ } Sfjs.renderAjaxRequests(); + + /* Handle toolbar-info position */ + var toolbarBlocks = document.getElementsByClassName('sf-toolbar-block'); + for (var i = 0; i < toolbarBlocks.length; i += 1) { + toolbarBlocks[i].onmouseover = function () { + var toolbarInfo = this.getElementsByClassName('sf-toolbar-info')[0]; + var pageWidth = document.body.clientWidth; + var elementWidth = toolbarInfo.offsetWidth; + var leftValue = (elementWidth + this.offsetLeft) - pageWidth; + var rightValue = (elementWidth + (pageWidth - this.offsetLeft)) - pageWidth; + + if (leftValue > 0 && rightValue > 0) { + toolbarInfo.style.right = (rightValue * -1) + 'px'; + } else if (leftValue < 0) { + toolbarInfo.style.left = 0; + } else { + toolbarInfo.style.right = '-1px'; + } + }; + } }, function(xhr) { if (xhr.status !== 0) {