Skip to content

Commit

Permalink
bar: support for debug bar at top of screen AJAX fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 26, 2018
1 parent ead5141 commit 7ac33a2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Tracy/assets/Bar/bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
setPosition(panel.elem, {
right: pos.right - getOffset(link).left + pos.width - getPosition(link).width - 4 + getOffset(panel.elem).left,
bottom: _this.isAtTop()
? getPosition(elem).bottom - pos.height - 4
? getPosition(_this.elem).bottom - pos.height - 4
: pos.bottom - getOffset(elem).top + pos.height + 4 + getOffset(panel.elem).top
});
}
Expand Down Expand Up @@ -313,14 +313,15 @@
};

Bar.prototype.savePosition = function() {
var pos = getPosition(document.getElementById(this.id));
localStorage.setItem(this.id, JSON.stringify({right: pos.right, bottom: pos.bottom}));
var pos = getPosition(this.elem),
atTop = this.isAtTop();
localStorage.setItem(this.id, JSON.stringify({right: pos.right, bottom: pos.bottom + (atTop ? pos.height : 0), atTop: atTop}));
};

Bar.prototype.restorePosition = function() {
var pos = JSON.parse(localStorage.getItem(this.id));
if (pos) {
setPosition(document.getElementById(this.id), pos);
setPosition(this.elem, {right: pos.right, bottom: pos.bottom - (pos.atTop ? getPosition(this.elem).height : 0)});
}
};

Expand Down Expand Up @@ -375,7 +376,11 @@
Debug.layer.insertAdjacentHTML('beforeend', content);
evalScripts(Debug.layer);
ajaxBar = document.getElementById('tracy-ajax-bar');
document.getElementById(Bar.prototype.id).appendChild(ajaxBar);
var oldPos = getPosition(Debug.bar.elem);
Debug.bar.elem.appendChild(ajaxBar);
if (Debug.bar.isAtTop()) {
setPosition(Debug.bar.elem, {right: oldPos.right, bottom: oldPos.bottom + oldPos.height - getPosition(Debug.bar.elem).height});
}

forEach(document.querySelectorAll('.tracy-panel'), function(panel) {
if (!Debug.panels[panel.id]) {
Expand Down

1 comment on commit 7ac33a2

@adrianbj
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice improvement - thanks, although I am not really sure that having the debug bar at the top of the screen is still very functional when the ajax bar is displayed. If you hover a panel icon on the main bar and then try to move the mouse to the panel, icons on the ajax bar are triggered and an ajax panel is displayed in instead. If you click a regular bar icon you can obviously get what you need, but it's still messy. That said I am not sure there is really a solution to this and that's probably ok. I don't imagine many would actually like the bar at the top of the screen anyway - it seems more in the way to me. So this is just an FYI, rather than a request for a fix.

Please sign in to comment.