10000 [2.2][WebProfilerBundle] Added minimize option to Web Profiler panels · markross/symfony@310c2f9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 310c2f9

Browse files
dlsniperfabpot
authored andcommitted
[2.2][WebProfilerBundle] Added minimize option to Web Profiler panels
1 parent c79584a commit 310c2f9

File tree

13 files changed

+243
-25
lines changed

13 files changed

+243
-25
l 6D40 ines changed

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ public function toolbarAction(Request $request, $token, $position = null)
186186
'profile' => $profile,
187187
'templates' => $this->getTemplateManager()->getTemplates($profile),
188188
'profiler_url' => $url,
189+
'token' => $token,
189190
));
190191
}
191192

src/Symfony/Bundle/WebProfilerBundle/Resources/public/css/profiler.css

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,14 @@ abbr {
104104

105105
#content {
106106
padding: 0 50px;
107-
margin: 0 auto;
107+
margin: 0 auto 20px;
108108
font-family: Arial, Helvetica, sans-serif;
109109
min-width: 970px;
110+
110111
}
111112

112113
#header {
113-
padding: 30px 30px 20px;
114+
padding: 20px 30px 20px;
114115
}
115116

116117
#header h1 {
@@ -131,6 +132,7 @@ abbr {
131132
padding-bottom: 0;
132133
display: block;
133134
background-color: #f6f6f6;
135+
z-index: 10000;
134136
}
135137

136138
#menu_profiler li a {
@@ -144,9 +146,9 @@ abbr {
144146

145147
#menu_profiler li a span.label {
146148
display: block;
147-
padding: 20px 20px 16px 65px;
148-
min-height: 24px;
149-
_height: 24px;
149+
padding: 20px 0px 16px 65px;
150+
min-height: 16px;
151+
overflow: hidden;
150152
}
151153

152154
#menu_profiler li a span.icon {
@@ -186,7 +188,7 @@ abbr {
186188

187189
#collector_content {
188190
margin-left: 250px;
189-
padding: 40px 50px;
191+
padding: 30px 40px 40px;
190192
}
191193

192194
#navigation {
@@ -235,8 +237,9 @@ li {
235237
#resume {
236238
background-color: #f6f6f6;
237239
border-bottom: 1px solid #dfdfdf;
238-
padding: 10px 50px;
239-
margin-left: 210px;
240+
padding: 18px 10px 0px;
241+
margin-left: 250px;
242+
height: 34px;
240243
color: #313131;
241244
font-size: 12px;
242245
-moz-border-radius-topright: 16px;
@@ -284,7 +287,9 @@ table th.value {
284287
}
285288

286289
.sf-exceptionreset .block_exception_detected .text_exception {
287-
width: 520px;
290+
left: 10px;
291+
right: 10px;
292+
width: 95%;
288293
}
289294

290295
.sf-exceptionreset .block_exception_detected .illustration_exception {
@@ -488,3 +493,20 @@ td.main, td.menu {
488493
border: 1px solid #999;
489494
border-width: 1px 0;
490495
}
496+
497+
.collapsed-menu-parents #resume,
498+
.collapsed-menu-parents #collector_content {
499+
margin-left: 60px !important;
500+
}
501+
502+
.collapsed-menu {
503+
width: 60px !important;
504+
}
505+
506+
.collapsed-menu span :not(.icon) {
507+
display: none !important;
508+
}
509+
510+
.collapsed-menu span.icon img {
511+
display: inline !important;
512+
}
Loading
Loading

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
"use strict";
135135
136136
var _drawingColors = {{ colors|json_encode|raw }},
137-
_storagePrefix = 'sf2/profiler/timeline',
137+
_storagePrefix = 'timeline/',
138138
_threshold = 1,
139139
_requests = requests,
140140
_maxRequestTime = maxRequestTime;
@@ -353,7 +353,7 @@
353353
};
354354
355355
this.getThreshold = function() {
356-
var threshold = localStorage.getItem(_storagePrefix + '/threshold');
356+
var threshold = Sfjs.getPreference(_storagePrefix + 'threshold');
357357
358358
if (threshold === null) {
359359
return _threshold;
@@ -368,7 +368,7 @@
368368
{
369369
_threshold = threshold;
370370
371-
localStorage.setItem(_storagePrefix + '/threshold', threshold);
371+
Sfjs.setPreference(_storagePrefix + 'threshold', threshold);
372372
373373
return this;
374374
};
@@ -423,6 +423,11 @@
423423
elementThresholdControl.onclick = canvasAutoUpdateOnThresholdChange;
424424
elementThresholdControl.onchange = canvasAutoUpdateOnThresholdChange;
425425
elementThresholdControl.onkeyup = canvasAutoUpdateOnThresholdChange;
426+
427+
window.setTimeout(function() {
428+
canvasAutoUpdateOnThresholdChange(null);
429+
}, 50);
430+
426431
//]]></script>
427432
{% endblock %}
428433

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/admin.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="search import clearfix">
1+
<div class="search import clearfix" id="adminBar">
22
<h3>
33
<img style="margin: 0 5px 0 0; vertical-align: middle; height: 16px" width="16" height="16" alt="Import" src="{{ asset('bundles/webprofiler/images/import.png') }}" />
44
Admin

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"use strict";
44
55
var noop = function() {},
6+
7+
profilerStorageKey = 'sf2/profiler/',
8+
69
request = function(url, onSuccess, onError, payload, options) {
710
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
811
options = options || {};
@@ -17,21 +20,48 @@
1720
};
1821
xhr.send(payload || '');
1922
},
23+
2024
hasClass = function(el, klass) {
2125
return el.className.match(new RegExp('\\b' + klass + '\\b'));
2226
},
27+
2328
removeClass = function(el, klass) {
2429
el.className = el.className.replace(new RegExp('\\b' + klass + '\\b'), ' ');
2530
},
31+
2632
addClass = function(el, klass) {
2733
if (!hasClass(el, klass)) { el.className += " " + klass; }
34+
},
35+
36+
getPreference = function(name) {
37+
if (!window.localStorage) {
38+
return null;
39+
}
40+
41+
return localStorage.getItem(profilerStorageKey + name);
42+
},
43+
44+
setPreference = function(name, value) {
45+
if (!window.localStorage) {
46+
return null;
47+
}
48+
49+
localStorage.setItem(profilerStorageKey + name, value);
2850
};
2951
3052
return {
3153
hasClass: hasClass,
54+
3255
removeClass: removeClass,
56+
3357
addClass: addClass,
58+
59+
getPreference: getPreference,
60+
61+
setPreference: setPreference,
62+
3463
request: request,
64+
3565
load: function(selector, url, onSuccess, onError, options) {
3666
var el = document.getElementById(selector);
3767
@@ -51,6 +81,7 @@
5181
5282
return this;
5383
},
84+
5485
toggle: function(selector, elOn, elOff) {
5586
var i,
5687
style,
@@ -66,7 +97,6 @@
6697
6798
return this;
6899
}
69-
70100
}
71101
})();
72102
/*]]>*/</script>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/header.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</h1>
55

66
<div class="search">
7-
<form method="get" action="http://symfony.com/search">
7+
<form method="get" action="http://symfony.com/search" target="_blank">
88
<div class="form_row">
99
<label for="search_id">
1010
<img src="{{ asset('bundles/webprofiler/images/profiler/grey_magnifier.png') }}" alt="Search on Symfony website"/>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
</li>
4444
{% endif %}
4545
{% endfor %}
46+
<li class="minimize">
47+
<a href="javascript:void(0);" title="Minimize toolbar" onclick="return toggleMenuPanels();">
48+
<span class="label">
49+
<span class="icon"><img id="minimizePanelIcon" src="{{ asset('bundles/webprofiler/images/profiler/left-arrow.png') }}" alt="" /></span>
50+
<strong>Minimize</strong>
51+
</span>
52+
</a>
53+
</li>
4654
</ul>
4755
{% endif %}
4856
{% render 'WebProfilerBundle:Profiler:searchBar' %}
@@ -51,4 +59,74 @@
5159
</div>
5260
</div>
5361
</div>
62+
63+
<script type="text/javascript">//<![CDATA[
64+
65+
function toggleMenuPanels(state, doSave) {
66+
var leftIconPath = "{{ asset('bundles/webprofiler/images/profiler/left-arrow.png')|e('js') }}",
67+
rightIconPath = "{{ asset('bundles/webprofiler/images/profiler/right-arrow.png')|e('js') }}",
68+
menu = document.getElementById('navigation'), savedState = Sfjs.getPreference('menu/displayState'),
69+
displayState, elem, className;
70+
71+
if (savedState == null) {
72+
savedState = 'block';
73+
}
74+
75+
displayState = state || (savedState == 'block' ? 'none' : 'block');
76+
77+
if (typeof doSave === 'undefined') {
78+
doSave = true;
79+
}
80+
81+
document.getElementById('searchBar').style.display = displayState;
82+
document.getElementById('adminBar').style.display = displayState;
83+
84+
if (displayState == 'block') {
85+
Sfjs.removeClass(menu, 'collapsed-menu');
86+
Sfjs.removeClass(menu.parentNode.parentNode, 'collapsed-menu-parents');
87+
88+
document.getElementById('minimizePanelIcon').src = leftIconPath;
89+
} else {
90+
Sfjs.addClass(menu, 'collapsed-menu');
91+
Sfjs.addClass(menu.parentNode.parentNode, 'collapsed-menu-parents');
92+
93+
document.getElementById('minimizePanelIcon').src = rightIconPath;
94+
}
95+
96+
if (doSave) {
97+
Sfjs.setPreference('menu/displayState', displayState);
98+
}
99+
100+
try {
101+
canvasAutoUpdateOnThresholdChange(null);
102+
} catch (err) {
103+
104+
}
105+
106+
return false;
107+
}
108+
109+
window.setTimeout(function() {
110+
var menuItems = document.getElementById('menu_profiler').getElementsByTagName('LI'),
111+
elem, value, child, displayState = Sfjs.getPreference('menu/displayState');
112+
113+
if (displayState == 'none') {
114+
toggleMenuPanels('none', false);
115+
}
116+
117+
for (elem in menuItems) {
118+
if (typeof(menuItems[elem].children) != 'undefined' &&
119+
menuItems[elem].children.length > 0) {
120+
child = menuItems[elem].children[0]
121+
122+
if (child.getAttribute('title') == '' ||
123+
child.getAttribute('title') == null) {
124+
value = child.text.replace(/^\s+/g, '').split('\n')[0].replace(/\s+$/g, '');
125+
child.setAttribute('title', value);
126+
}
127+
}
128+
}
129+
}, 25);
130+
131+
//]]></script>
54132
{% endblock %}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/search.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="search clearfix">
1+
<div class="search clearfix" id="searchBar">
22
<h3>
33
<img style="margin: 0 5px 0 0; vertical-align: middle;" width="16" height="16" alt="Search" src="{{ asset('bundles/webprofiler/images/search.png') }}" />
44
Search

0 commit comments

Comments
 (0)
0