Skip to content

Commit 04a13ae

Browse files
committed
sqlformatter test
1 parent c252ab7 commit 04a13ae

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Resources/queries/widget.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,25 @@
252252
}
253253
}).prependTo($li);
254254
}
255+
256+
if (window.sqlFormatter) {
257+
$('<span title="Format Query" />').on('click', function () {
258+
event.stopPropagation();
259+
let popup = window.open('about:blank', 'SQL Pretty-Print', 'width=700,height=440,scrollbars=yes'),
260+
documentToWriteTo = popup.document,
261+
cssLink = document.querySelector('link[href*="debugbar/assets/stylesheets"]')
262+
body = $('<div class="phpdebugbar" />').append(
263+
$('<pre style="border: 1px solid #ddd; padding: 5px;" />').append(
264+
$('<code class="phpdebugbar-widgets-sql" />')
265+
.html(PhpDebugBar.Widgets.highlight(sqlFormatter.format(statement.sql), 'sql'))
266+
));
267+
268+
let css = '<style>body{margin:0;padding:0;}div.phpdebugbar{position:relative;padding:10px;width:auto;}</style>';
269+
documentToWriteTo.open();
270+
documentToWriteTo.write((cssLink ? $(cssLink).prop('outerHTML') : '') + css + body.prop('outerHTML'));
271+
documentToWriteTo.close();
272+
}).addClass(csscls('code-format')).prependTo($li);
273+
}
255274
}
256275

257276
if (statement.width_percent) {

0 commit comments

Comments
 (0)