From 02a2acadbf4c1e86674c04c286c162b70d8f0aba Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 20 Mar 2024 10:01:36 +0100 Subject: [PATCH] Track history --- src/DebugBar/Resources/debugbar.js | 2 ++ src/DebugBar/Resources/widgets.js | 37 +++++++++++++++++------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/DebugBar/Resources/debugbar.js b/src/DebugBar/Resources/debugbar.js index 56aa384..58f4114 100644 --- a/src/DebugBar/Resources/debugbar.js +++ b/src/DebugBar/Resources/debugbar.js @@ -421,6 +421,7 @@ if (typeof(PhpDebugBar) == 'undefined') { this.dataMap = {}; this.datasets = {}; this.firstTabName = null; + this.previousPanelName = null; this.activePanelName = null; this.activeDatasetId = null; this.datesetTitleFormater = new DatasetTitleFormater(this); @@ -785,6 +786,7 @@ if (typeof(PhpDebugBar) == 'undefined') { this.controls[name].$tab.addClass(csscls('active')); this.controls[name].$el.addClass(csscls('active')); + this.previousPanelName = this.activePanelName; this.activePanelName = name; this.$el.removeClass(csscls('minimized')); diff --git a/src/DebugBar/Resources/widgets.js b/src/DebugBar/Resources/widgets.js index d5d64f0..b809f58 100644 --- a/src/DebugBar/Resources/widgets.js +++ b/src/DebugBar/Resources/widgets.js @@ -790,25 +790,33 @@ if (typeof(PhpDebugBar) == 'undefined') { var $badges = $(''); var tr = $(''); - console.log('sorting ' , widget.get('sort')); if (widget.get('sort') === 'asc') { tr.appendTo(widget.$table); } else { - console.log('prepend'); tr.prependTo(widget.$table); } + var clickHandler = function() { + var debugbar = widget.get('debugbar'); + debugbar.showDataSet(meta['id']); + widget.$table.find('.' + csscls('active')).removeClass(csscls('active')); + tr.addClass(csscls('active')); + + if ($(this).data('tab')) { + debugbar.showTab($(this).data('tab')); + } else if (debugbar.previousPanelName) { + debugbar.showTab(debugbar.previousPanelName); + } else { + debugbar.showTab(debugbar.firstTabName); + } + } + tr.attr('data-id', meta['id']) - .append('#' + meta['nb'] + '') - .append('' + meta['datetime'] + '') - .append('' + meta['method'] + '') - .append($('').append(meta['uri'] + (meta['suffix'] ? ' ' + meta['suffix'] : ''))) + .append($('#' + meta['nb'] + '').click(clickHandler)) + .append($('' + meta['datetime'] + '').click(clickHandler)) + .append($('' + meta['method'] + '').click(clickHandler)) + .append($('').append(meta['uri'] + (meta['suffix'] ? ' ' + meta['suffix'] : '')).click(clickHandler)) .css('cursor', 'pointer') - .on('click', function() { - widget.get('debugbar').showDataSet(meta['id']); - widget.$table.find('.' + csscls('active')).removeClass(csscls('active')); - tr.addClass(csscls('active')); - }) .addClass(csscls('table-row')) var debugbar = widget.get('debugbar'); @@ -818,17 +826,14 @@ if (typeof(PhpDebugBar) == 'undefined') { key = key.split(':'); if (key[1] === 'badge' && d > 0) { var control = debugbar.getControl(key[0]); - var $a = $('').attr('title', control.get('title')); + var $a = $('').attr('title', control.get('title')).data('tab', key[0]); if (control.$icon) { $a.append(debugbar.getControl(key[0]).$icon.clone()); } if (control.$badge) { $a.append(debugbar.getControl(key[0]).$badge.clone().css('display', 'inline-block').text(d)); } - $a.appendTo($badges); - $a.click(function() { - debugbar.showTab(key[0]); - }) + $a.appendTo($badges).click(clickHandler); } } });