-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deployed f44de7a with MkDocs version: 1.5.3
- Loading branch information
1 parent
17b3aa6
commit f3b966c
Showing
47 changed files
with
3,953 additions
and
34,065 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Description: Open external links in a new tab and PDF links in a new tab | ||
// Source: https://jekyllcodex.org/without-plugin/new-window-fix/ | ||
|
||
//open external links in a new window | ||
function external_new_window() { | ||
for(let c = document.getElementsByTagName("a"), a = 0;a < c.length;a++) { | ||
let b = c[a]; | ||
if(b.getAttribute("href") && b.hostname !== location.hostname) { | ||
b.target = "_blank"; | ||
b.rel = "noopener"; | ||
} | ||
} | ||
} | ||
//open PDF links in a new window | ||
function pdf_new_window () | ||
{ | ||
if (!document.getElementsByTagName) { | ||
return false; | ||
} | ||
let links = document.getElementsByTagName("a"); | ||
for (let eleLink=0; eleLink < links.length; eleLink ++) { | ||
if ((links[eleLink].href.indexOf('.pdf') !== -1)||(links[eleLink].href.indexOf('.doc') !== -1)||(links[eleLink].href.indexOf('.docx') !== -1)) { | ||
links[eleLink].onclick = | ||
function() { | ||
window.open(this.href); | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
|
||
function apply_rules() { | ||
external_new_window(); | ||
pdf_new_window(); | ||
} | ||
|
||
if (typeof document$ !== "undefined") { | ||
// compatibility with mkdocs-material's instant loading feature | ||
// based on code from https://github.com/timvink/mkdocs-charts-plugin | ||
// Copyright (c) 2021 Tim Vink - MIT License | ||
// fixes [Issue #2](https://github.com/JakubAndrysek/mkdocs-open-in-new-tab/issues/2) | ||
document$.subscribe(function() { | ||
apply_rules(); | ||
}) | ||
} |
Oops, something went wrong.