Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFR] Persistent toggle Toolbar #44

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Fabfuel/Prophiler/View/css/screen.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 33 additions & 5 deletions src/Fabfuel/Prophiler/View/sass/screen.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@import "compass/css3";
@import "compass/utilities/general/clearfix";

$c-background: #f8f8f8;
$c-lines: #eee;
$c-headline: #777;

Expand All @@ -12,26 +13,53 @@ $c-event-blue: rgba(57, 126, 185, .75);
$c-event-sky: rgba(96, 194, 223, .75);
$c-event-grey: rgba(216, 216, 216, 0.75);

$z-index: 10000;

body {
margin-top: 33px !important;
position: relative;
}

#skel-layers-wrapper {
-webkit-perspective: none !important;
}

#prophiler-toggle {
position: fixed;
top: 0;
left: 0;
z-index: $z-index;
background-color: $c-background;
border-radius: 0 0 6px 0;

a {
visibility: hidden;
display: block;
border: none;
padding: 0 8px;
line-height: 32px;
height: 37px;
&:after {
content: '\25b2';
}
&.prophiler-hidden:after {
content: '\25bc';
}
}
}

#prophiler {
visibility: hidden;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
font-size: 12px;
line-height: 1.42857143;
position: fixed;
display: block;
padding-left: 24px;
top: 0;
left: 0;
right: 0;
z-index: 10000;
background-color: #fff;
z-index: $z-index;
background-color: $c-background;
opacity: 0.97;
@include box-shadow(0 3px 10px rgba(0, 0, 0, .125));

Expand Down Expand Up @@ -153,15 +181,15 @@ body {

min-height: 31px;
border: 1px solid transparent;
background-color: #f8f8f8;
background-color: $c-background;
border-color: #e7e7e7;

h1 {
color: $c-headline;
float: left;
padding: 5px 15px;
font-size: 18px;
line-height: 20px;
line-height: 22px;
margin: 0;
}

Expand Down
41 changes: 41 additions & 0 deletions src/Fabfuel/Prophiler/View/toolbar.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use Fabfuel\Prophiler\Toolbar\Formatter\BenchmarkFormatter;
<div id="prophiler">

<div class="toolbar">

<h1 class="logo">Prophiler</h1>

<nav>
Expand Down Expand Up @@ -79,15 +80,55 @@ use Fabfuel\Prophiler\Toolbar\Formatter\BenchmarkFormatter;
<?php foreach ($aggregators as $aggregator): ?>
<?php $this->partial('partials/aggregator', ['profiler' => $profiler, 'aggregator' => $aggregator]); ?>
<?php endforeach; ?>

</div>

<div id="prophiler-toggle">
<a href="javascript:void(0);"></a>
</div>

<script>

if (!window.jQuery) {
document.write('<script src="//code.jquery.com/jquery-2.1.1.min.js"><\/script>');
}
window.addEventListener("load", function () {
$('json').each(function (index, el) {
el.innerHTML = JSON.stringify(JSON.parse(el.innerHTML), null, ' ');
});

// A bit more optimized
var $body = $('body');
var $prophiler = $('#prophiler');
var $prophilerToggle = $('#prophiler-toggle a');
var height = parseFloat($prophilerToggle.outerHeight())+'px';

$prophilerToggle.on('click', function() {
var visible = !$(this).toggleClass('prophiler-hidden').hasClass('prophiler-hidden');
if(visible) {
$body.clearQueue().animate({marginTop:height},'fast');
$prophiler.clearQueue().slideDown('fast');
document.cookie = 'prophiler_toolbar_hidden=; max-age=0; path=/';
} else {
$body.clearQueue().animate({marginTop:'0'},'fast');
$prophiler.clearQueue().slideUp('fast');
document.cookie = 'prophiler_toolbar_hidden=1; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/';
}
});

// Persistent toolbar state
if(document.cookie.match(/(^|;)\s*prophiler_toolbar_hidden\s*=/)) {
$body.css({marginTop:0});
$prophiler.hide();
$prophilerToggle.addClass('prophiler-hidden');
} else {
$body.css({marginTop:height});
$prophiler.show();
$prophilerToggle.removeClass('prophiler-hidden');
}

// Minimize jumpy loading
$prophilerToggle.css({visibility:'visible'});
$prophiler.css({visibility:'visible'});
});
</script>