Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/brackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,22 @@ define(function (require, exports, module) {
e.preventDefault();
}
});

// Prevent clicks on any link from navigating to a different page (which could lose unsaved
// changes). We can't use a simple .on("click", "a") because of http://bugs.jquery.com/ticket/3861:
// jQuery hides non-left clicks from such event handlers, yet middle-clicks still cause CEF to
// navigate. Also, a capture handler is more reliable than bubble.
window.document.body.addEventListener("click", function (e) {
// Check parents too, in case link has inline formatting tags
var node = e.target;
while (node) {
if (node.tagName === "A") {
e.preventDefault();
break;
}
node = node.parentElement;
}
}, true);
}

// Dispatch htmlReady event
Expand Down
1 change: 0 additions & 1 deletion src/extensibility/ExtensionManagerDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ define(function (require, exports, module) {
// Dialog tabs
$dlg.find(".nav-tabs a")
.on("click", function (event) {
event.preventDefault();
$(this).tab("show");
});

Expand Down
5 changes: 0 additions & 5 deletions src/extensibility/ExtensionManagerView.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ define(function (require, exports, module) {
// UI event handlers
this.$el
.on("click", "a", function (e) {
// Never allow the default behavior for links--we don't want
// them to navigate out of Brackets!
e.stopImmediatePropagation();
e.preventDefault();

var $target = $(e.target);
if ($target.hasClass("undo-remove")) {
ExtensionManager.markForRemoval($target.attr("data-extension-id"), false);
Expand Down
1 change: 0 additions & 1 deletion src/extensions/default/WebPlatformDocs/InlineDocsViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ define(function (require, exports, module) {

/** Clicking any link should open it in browser, not in Brackets shell */
InlineDocsViewer.prototype._handleLinkClick = function (event) {
event.preventDefault();
var url = $(event.currentTarget).attr("href");
if (url) {
NativeApp.openURLInDefaultBrowser(url);
Expand Down