Skip to content

Commit 77d3413

Browse files
committed
Prevent opening image dropped on news window
1 parent 52857b1 commit 77d3413

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/functions.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,25 @@ function show_news() {
17661766
$news_window.center(); // @XXX - but it helps tho
17671767

17681768
$latest_news.attr("tabIndex", "-1").focus();
1769+
1770+
// Prevent opening images dropped on news window
1771+
// especially those dragged from the news window itself (accidentally or habitually/idly)
1772+
// TODO: should this be for all windows?
1773+
$news_window.on("dragover", (event) => {
1774+
// the default behavior is to not allow dropping,
1775+
// so don't prevent the default, but do stop propagation
1776+
// so that the global handler doesn't allow the drop
1777+
event.stopPropagation();
1778+
});
1779+
$news_window.on("dragenter", (event) => {
1780+
// same as dragover, but just prevents flickering of the cursor basically,
1781+
// when dragover is already handled
1782+
event.stopPropagation();
1783+
});
1784+
$news_window.on("drop", (event) => {
1785+
event.preventDefault();
1786+
event.stopPropagation();
1787+
});
17691788
}
17701789

17711790

0 commit comments

Comments
 (0)