Skip to content

Commit 086f07f

Browse files
authored
Avoid js alert on copy, and avoid params opening on link click (#1659)
* Avoit js `alert` on copy, and avoid params opening on link click * Other fixes
1 parent 8e8c83f commit 086f07f

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

src/Resources/queries/widget.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
var isCopied = false;
3232
try {
3333
isCopied = document.execCommand('copy');
34-
alert('Query copied to the clipboard');
34+
console.log('Query copied to the clipboard');
3535
} catch (err) {
36-
console.log('Oops, unable to copy');
36+
alert('Oops, unable to copy');
3737
}
3838

3939
window.getSelection().removeAllRanges();
@@ -280,25 +280,20 @@
280280
$li.append($('<span title="Connection" />').addClass(csscls('database')).text(statement.connection));
281281
}
282282
if (statement.xdebug_link) {
283-
const $header = $('<span title="Filename" />')
283+
$('<span title="Filename" />')
284284
.addClass(csscls('filename'))
285-
.text(statement.xdebug_link.line ? `${statement.xdebug_link.filename}#${statement.xdebug_link.line}` : statement.xdebug_link.filename);
286-
287-
if (statement.xdebug_link.ajax) {
288-
$header.append(
289-
$('<a/>')
290-
.attr('title', statement.xdebug_link.url)
291-
.addClass(csscls('editor-link'))
292-
.on('click', () => fetch(statement.xdebug_link.url))
293-
);
294-
} else {
295-
$header.append(
296-
$('<a/>')
297-
.attr('href', statement.xdebug_link.url)
298-
.addClass(csscls('editor-link'))
299-
);
300-
}
301-
$li.append($header);
285+
.text(statement.xdebug_link.filename + '#' + (statement.xdebug_link.line || '?'))
286+
.append($('<a/>')
287+
.attr('href', statement.xdebug_link.url)
288+
.addClass(csscls('editor-link'))
289+
.on('click', event => {
290+
event.stopPropagation();
291+
if (statement.xdebug_link.ajax) {
292+
event.preventDefault();
293+
fetch(statement.xdebug_link.url);
294+
}
295+
})
296+
).appendTo($li);
302297
}
303298

304299
const $details = $('<table></table>').addClass(csscls('params'))

0 commit comments

Comments
 (0)