Skip to content

Commit

Permalink
Enable copy, tweak icon (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh authored Sep 10, 2024
1 parent 4eb7fd7 commit ce4762b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/DebugBar/Resources/widgets/sqlqueries/widget.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ div.phpdebugbar-widgets-sqlqueries span.phpdebugbar-widgets-stmt-id:before {
}
div.phpdebugbar-widgets-sqlqueries span.phpdebugbar-widgets-copy-clipboard:before {
content: "\f0c5";
line-height: 1.5;
}
div.phpdebugbar-widgets-sqlqueries span.phpdebugbar-widgets-copy-clipboard-check:before {
content: "\f46c";
}
div.phpdebugbar-widgets-sqlqueries a.phpdebugbar-widgets-editor-link:before {
content: "\f08e";
Expand Down
7 changes: 5 additions & 2 deletions src/DebugBar/Resources/widgets/sqlqueries/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
var copy = function () {
try {
document.execCommand('copy');
alert('Query copied to the clipboard');
$(el).addClass(csscls('copy-clipboard-check'));
setTimeout(function(){
$(el).removeClass(csscls('copy-clipboard-check'));
}, 2000)
} catch (err) {
console.log('Oops, unable to copy');
}
Expand Down Expand Up @@ -116,7 +119,7 @@
li.addClass(csscls('error'));
li.append($('<span />').addClass(csscls('error')).text("[" + stmt.error_code + "] " + stmt.error_message));
}
if ((!stmt.type || stmt.type === 'query') && stmt.show_copy !== false) {
if ((!stmt.type || stmt.type === 'query')) {
$('<span title="Copy to clipboard" />')
.addClass(csscls('copy-clipboard'))
.css('cursor', 'pointer')
Expand Down

0 comments on commit ce4762b

Please sign in to comment.