Skip to content

Commit 8e8c83f

Browse files
authored
Tweak copy query, remove alert and change icon (#1658)
1 parent cc241eb commit 8e8c83f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"require": {
1313
"php": "^8.0",
14-
"maximebf/debugbar": "~1.22.4",
14+
"maximebf/debugbar": "~1.23.0",
1515
"illuminate/routing": "^9|^10|^11",
1616
"illuminate/session": "^9|^10|^11",
1717
"illuminate/support": "^9|^10|^11",

src/Resources/queries/widget.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@
2828
window.getSelection().addRange(range);
2929
}
3030

31+
var isCopied = false;
3132
try {
32-
document.execCommand('copy');
33+
isCopied = document.execCommand('copy');
3334
alert('Query copied to the clipboard');
3435
} catch (err) {
3536
console.log('Oops, unable to copy');
3637
}
3738

3839
window.getSelection().removeAllRanges();
40+
41+
return isCopied;
3942
},
4043

4144
explainMysql: function ($element, statement, rows) {
@@ -235,9 +238,15 @@
235238
$('<span title="Copy to clipboard" />')
236239
.addClass(csscls('copy-clipboard'))
237240
.css('cursor', 'pointer')
241+
.html("&#8203;")
238242
.on('click', (event) => {
239243
event.stopPropagation();
240-
this.copyToClipboard($code.get(0));
244+
if (this.copyToClipboard($code.get(0))) {
245+
$(event.target).addClass(csscls('copy-clipboard-check'));
246+
setTimeout(function(){
247+
$(event.target).removeClass(csscls('copy-clipboard-check'));
248+
}, 2000)
249+
}
241250
})
242251
);
243252
}

0 commit comments

Comments
 (0)