Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds external link icons to main nav #219

Merged
merged 2 commits into from
Mar 3, 2020
Merged
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
22 changes: 21 additions & 1 deletion _static/js/custom.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
$( document ).ready(function() {

// Create link and text for navigation back to the OLCF home page
var olcf_link = document.createElement("a");
var olcf_text = document.createTextNode("OLCF Home Page");
Expand All @@ -17,7 +18,7 @@ $( document ).ready(function() {
aside.appendChild(separator);
aside.appendChild(olcf_link);

// Insert Project Name "OLCF User Documentation" below html_logo in sidebar navigation
// Insert Project Name "OLCF User Documentation" below html_logo in sidebar navigation
var project_name_link = document.createElement("a");
var project_name_text = document.createTextNode(" OLCF User Documentation");
project_name_link.appendChild(project_name_text);
Expand All @@ -26,4 +27,23 @@ $( document ).ready(function() {
project_name_link.classList.add("icon-home");
wysidenavsearch = document.querySelector("body > div > nav > div > div.wy-side-nav-search > a");
wysidenavsearch.appendChild(project_name_link);


// For any external links in the main navigation, append the FontAwesome external link icon.
function iconize_external_links(nav_level){
a_elements = nav_level.getElementsByTagName("A");
for (var i = 0; i < a_elements.length; ++i){
if (a_elements[i].getAttribute("href").includes("http")){
var icon = document.createElement("i");
icon.classList.add("fa");
icon.classList.add("fa-external-link");
var spacer = document.createTextNode(" ");
a_elements[i].appendChild(spacer);
a_elements[i].appendChild(icon);
}
}
}

iconize_external_links(document.querySelector("body > div > nav > div > div.wy-menu.wy-menu-vertical"))

});