Skip to content

[WebProfilerBundle] Added preview iframe for built-in IDE links #21045

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

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
iframe#sfpreview {
display: none;
position: fixed;
bottom: 0;
left: 0;
height: 80%;
width: 100%;
z-index: 99995; {# Behind toolbar, above profiler menu and dumps #}
}
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,77 @@
toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;
});
}
},

createIdeLinks: function() {
var links = document.querySelectorAll('a[href^="'+window.location.protocol+'//'+window.location.host+'/_profiler/open"]');
if (links.length === 0) {
return;
}

var target = document.getElementById('sfpreview');
if (!target) {
target = document.createElement('iframe');
target.setAttribute('id', 'sfpreview');
target.setAttribute('src', 'javascript:;');

addEventListener(target, 'load', function() {
if (target.src === 'javascript:;') {
return;
}

var contentDoc = (target.contentDocument || target.contentWindow.document),
close = contentDoc.querySelector('a.close');
addEventListener(close, 'click', function() {
target.style.display = 'none';
});
addEventListener(contentDoc.body, 'click', function() {
target.style.height = '80%';
target.setAttribute('scrolling', 'auto');
});
close.style.display = 'block';
target.style.display = 'block';
});

var toolbar = document.querySelector('.sf-toolbar');
addEventListener(document.body, 'click', function(e) {
if (toolbar) {
var node = e.target.parentNode;
while (node) {
if (node === toolbar) {
return;
}
node = node.parentNode;
}
}

target.style.height = '20%';
target.setAttribute('scrolling', 'no');
});

(toolbar || document.body).appendChild(target);
}

for (var i = 0; i < links.length; i++) {
addEventListener(links[i], 'click', function(e) {
e.preventDefault();
e.stopPropagation();

if (target.getAttribute('src') === this.getAttribute('href')) {
target.style.display = 'block';
} else {
target.setAttribute('src', this.getAttribute('href'));
}
})
}
}
};
})();

Sfjs.addEventListener(window, 'load', function() {
Sfjs.createTabs();
Sfjs.createToggles();
Sfjs.createIdeLinks();
Sfjs.renderAjaxRequests();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,23 @@ body {
word-break: break-all;
}

a.doc {
a.doc,
a.close {
color: #FFF;
text-decoration: none;
margin: auto;
margin-right: 10px;
margin: auto 10px auto 0;
}

a.close {
display: none;
}

a.doc {
margin-left: auto;
}

a.doc:hover {
a.doc:hover,
a.close:hover {
text-decoration: underline;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<div class="header">
<h1>{{ file }} <small>line {{ line }}</small></h1>
<a class="doc" href="https://symfony.com/doc/{{ constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') }}/reference/configuration/framework.html#ide" rel="help">Open in your IDE?</a>
<a class="close" href="javascript:;" rel="close">Close panel</a>
</div>
<div class="source">
{{ filename|file_excerpt(line, -1) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
========================================================================= #}
html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid silver}legend{padding:0;border:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0}

{# Shared styles
========================================================================= #}
{{ include('@WebProfiler/Profiler/base.css.twig') }}

{# Basic styles
========================================================================= #}
html, body {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{# shared styles #}
{{ include('@WebProfiler/Profiler/base.css.twig') }}

{# when updating any of these colors, do the same in profiler.css.twig #}
{% set colors = { 'success': '#4F805D', 'warning': '#A46A1F', 'error': '#B0413E' } %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/* Handle toolbar-info position */
var toolbarBlocks = [].slice.call(el.querySelectorAll('.sf-toolbar-block'));
for (i = 0; i < toolbarBlocks.length; ++i) {
toolbarBlocks[i].onmouseover = function () {
Sfjs.addEventListener(toolbarBlocks[i], 'mouseover', function () {
var toolbarInfo = this.querySelectorAll('.sf-toolbar-info')[0];
var pageWidth = document.body.clientWidth;
var elementWidth = toolbarInfo.offsetWidth;
Expand All @@ -62,7 +62,7 @@
} else {
toolbarInfo.style.right = '0px';
}
};
});
}
Sfjs.addEventListener(document.getElementById('sfToolbarHideButton-{{ token }}'), 'click', function (event) {
event.preventDefault();
Expand All @@ -88,7 +88,8 @@
}

Sfjs.setPreference('toolbar/displayState', 'block');
})
});
Sfjs.createIdeLinks();
},
function(xhr) {
if (xhr.status !== 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class HtmlDumper extends CliDumper
protected $headerIsDumped = false;
protected $lastDepth = -1;
protected $styles = array(
'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all',
'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99990; word-break: break-all',
'num' => 'font-weight:bold; color:#1299DA',
'const' => 'font-weight:bold',
'str' => 'font-weight:bold; color:#56DB3A',
Expand Down