mirror of
https://github.com/maximebf/php-debugbar.git
synced 2025-07-24 18:22:03 +02:00
Simplify
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the DebugBar package.
|
||||
*
|
||||
* (c) 2013 Maxime Bouroumeau-Fuseau
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace DebugBar\DataCollector;
|
||||
|
||||
/**
|
||||
* Collects array data
|
||||
*/
|
||||
class DatasetCollector extends DataCollector implements Renderable, AssetProvider
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function collect()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'Datasets';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getWidgets()
|
||||
{
|
||||
return array(
|
||||
"__datasets" => array(
|
||||
"icon" => "history",
|
||||
"title" => "Requests",
|
||||
"widget" => 'PhpDebugBar.Widgets.DatasetListWidget',
|
||||
"default" => "{}",
|
||||
"position" => "right"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function getAssets()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
@@ -11,7 +11,6 @@
|
||||
namespace DebugBar;
|
||||
|
||||
use DebugBar\DataCollector\AssetProvider;
|
||||
use DebugBar\DataCollector\DatasetCollector;
|
||||
use DebugBar\DataCollector\Renderable;
|
||||
|
||||
/**
|
||||
@@ -1125,8 +1124,7 @@ class JavascriptRenderer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$controls = array_merge($widgets, $this->controls, (new DatasetCollector())->getWidgets());
|
||||
$controls = array_merge($widgets, $this->controls);
|
||||
|
||||
foreach (array_filter($controls) as $name => $options) {
|
||||
$opts = array_diff_key($options, array_flip($excludedOptions));
|
||||
@@ -1135,13 +1133,12 @@ class JavascriptRenderer
|
||||
if (!isset($opts['title'])) {
|
||||
$opts['title'] = ucfirst(str_replace('_', ' ', $name));
|
||||
}
|
||||
$js .= sprintf("%s.addTab(\"%s\", new %s({%s%s}), \"%s\");\n",
|
||||
$js .= sprintf("%s.addTab(\"%s\", new %s({%s%s}));\n",
|
||||
$varname,
|
||||
$name,
|
||||
isset($options['tab']) ? $options['tab'] : 'PhpDebugBar.DebugBar.Tab',
|
||||
substr(json_encode($opts, JSON_FORCE_OBJECT), 1, -1),
|
||||
isset($options['widget']) ? sprintf('%s"widget": new %s()', count($opts) ? ', ' : '', $options['widget']) : '',
|
||||
isset($options['position']) ? $options['position'] : 'left'
|
||||
isset($options['widget']) ? sprintf('%s"widget": new %s()', count($opts) ? ', ' : '', $options['widget']) : ''
|
||||
);
|
||||
} elseif (isset($options['indicator']) || isset($options['icon'])) {
|
||||
$js .= sprintf("%s.addIndicator(\"%s\", new %s(%s), \"%s\");\n",
|
||||
|
@@ -455,7 +455,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
|
||||
}
|
||||
|
||||
var currentSize = this.$header.width();
|
||||
var cssClass = "phpdebugbar-mini-design";
|
||||
var cssClass = csscls("mini-design");
|
||||
var bool = this.$header.hasClass(cssClass);
|
||||
|
||||
if (currentSize <= contentSize && !bool) {
|
||||
@@ -490,7 +490,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
|
||||
self.close();
|
||||
});
|
||||
this.$headerLeft = $('<div />').addClass(csscls('header-left')).appendTo(this.$header);
|
||||
this.$headerRight = $('<div />').addClass(csscls('header-right')).appendTo(this.$header);
|
||||
this.$headerRight = $('<div />').addClass(csscls('header-right'), csscls('mini-design')).appendTo(this.$header);
|
||||
var $body = this.$body = $('<div />').addClass(csscls('body')).appendTo(this.$el);
|
||||
this.recomputeBottomOffset();
|
||||
|
||||
@@ -544,6 +544,17 @@ if (typeof(PhpDebugBar) == 'undefined') {
|
||||
});
|
||||
});
|
||||
|
||||
this.datasetTab = new PhpDebugBar.DebugBar.Tab({"icon":"history", "title":"History", "widget": new PhpDebugBar.Widgets.DatasetWidget()});
|
||||
this.datasetTab.$tab.appendTo( this.$headerRight).hide();
|
||||
this.datasetTab.$tab.click(function() {
|
||||
if (!self.isMinimized() && self.activePanelName == '__datasets') {
|
||||
self.minimize();
|
||||
} else {
|
||||
self.showTab('__datasets');
|
||||
}
|
||||
});
|
||||
this.datasetTab.$el.appendTo(this.$body);
|
||||
this.controls['__datasets'] = this.datasetTab;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -617,13 +628,13 @@ if (typeof(PhpDebugBar) == 'undefined') {
|
||||
* @param {Tab} tab Tab object
|
||||
* @return {Tab}
|
||||
*/
|
||||
addTab: function(name, tab, position) {
|
||||
addTab: function(name, tab) {
|
||||
if (this.isControl(name)) {
|
||||
throw new Error(name + ' already exists');
|
||||
}
|
||||
|
||||
var self = this;
|
||||
tab.$tab.appendTo(position == 'right' ? this.$headerRight : this.$headerLeft).click(function() {
|
||||
tab.$tab.appendTo( this.$headerLeft).click(function() {
|
||||
if (!self.isMinimized() && self.activePanelName == name) {
|
||||
self.minimize();
|
||||
} else {
|
||||
@@ -936,9 +947,9 @@ if (typeof(PhpDebugBar) == 'undefined') {
|
||||
id = id || (getObjectSize(this.datasets) + 1);
|
||||
this.datasets[id] = data;
|
||||
|
||||
var control = this.getControl('__datasets');
|
||||
control.set('data', this.datasets);
|
||||
control.set('badge', getObjectSize(this.datasets));
|
||||
this.datasetTab.$tab.show();
|
||||
this.datasetTab.set('data', this.datasets);
|
||||
this.datasetTab.set('badge', getObjectSize(this.datasets));
|
||||
|
||||
if (typeof(show) == 'undefined' || show) {
|
||||
this.showDataSet(id);
|
||||
|
@@ -276,7 +276,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
|
||||
* Options:
|
||||
* - data
|
||||
*/
|
||||
var DatasetListWidget = PhpDebugBar.Widgets.DatasetListWidget = KVListWidget.extend({
|
||||
var DatasetWidget = PhpDebugBar.Widgets.DatasetWidget = KVListWidget.extend({
|
||||
|
||||
className: csscls('kvlist datasetlist'),
|
||||
|
||||
|
Reference in New Issue
Block a user