-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
turn dashboard.js into a module (#3698)
- Loading branch information
Showing
3 changed files
with
30 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,11 @@ | ||
'use strict'; | ||
|
||
jQuery(function(){ | ||
$("a[target=_blank]").on("click", function(event) { | ||
// open url using javascript, instead of following directly | ||
event.preventDefault(); | ||
import { openLinkInJs } from './utils'; | ||
|
||
if(window.open($(this).attr("href")) == null){ | ||
// link was not opened in new window, so display error msg to user | ||
const html = $("#js-alert-danger-template").html(); | ||
const msg = "This link is configured to open in a new window, but it doesn't seem to have opened. " + | ||
"Please disable your popup blocker for this page and try again."; | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const anchors = document.querySelectorAll('a[target=_blank]'); | ||
|
||
// replace message in alert and add to main div of layout | ||
$("div[role=main]").prepend(html.split("ALERT_MSG").join(msg)); | ||
} | ||
anchors.forEach(anchor => { | ||
anchor.addEventListener('click', (event) => { openLinkInJs(event); }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters