From a36d37dae69c00c13048ffe032316ff5ce7b71bb Mon Sep 17 00:00:00 2001 From: John Mulhausen Date: Fri, 21 Apr 2017 14:31:23 -0700 Subject: [PATCH] Fix for glossary --- _layouts/docs.html | 12 ++++++++ js/docs.js | 69 ++++++++++++++++++++++++---------------------- js/menu.js | 15 ++-------- 3 files changed, 51 insertions(+), 45 deletions(-) diff --git a/_layouts/docs.html b/_layouts/docs.html index 4138d77d41..ff8af32e66 100644 --- a/_layouts/docs.html +++ b/_layouts/docs.html @@ -217,6 +217,18 @@ else %}{% assign edit_url = "" %}{% endif %} {% break %} {% endif %} {% endfor % + diff --git a/js/docs.js b/js/docs.js index 2a1929b547..dc0c627305 100644 --- a/js/docs.js +++ b/js/docs.js @@ -16,42 +16,45 @@ if (current[0]) { function highlightRightNav(heading) { - if (heading == "title") - { - history.replaceState({},"Top of page on " + document.location.pathname,document.location.protocol +"//"+ document.location.hostname + (location.port ? ':'+location.port: '') + document.location.pathname); - $("#my_toc a").each(function(){ - $(this).removeClass("active"); - }); - $("#sidebar-wrapper").animate({ - scrollTop: 0 - },800); - } else { - var targetAnchorHREF = document.location.protocol +"//"+ document.location.hostname + (location.port ? ':'+location.port: '') + document.location.pathname + "#" + heading; - // make sure we aren't filtering out that heading level - var noFilterFound = false; - $("#my_toc a").each(function(){ - if (this.href==targetAnchorHREF) { - noFilterFound = true; - } - }); - // now, highlight that heading - if (noFilterFound) + if (document.location.pathname.indexOf("/glossary/")<0){ + console.log("highlightRightNav called on",document.location.pathname) + if (heading == "title") { + history.replaceState({},"Top of page on " + document.location.pathname,document.location.protocol +"//"+ document.location.hostname + (location.port ? ':'+location.port: '') + document.location.pathname); $("#my_toc a").each(function(){ - //console.log("right-nav",this.href); - if (this.href==targetAnchorHREF) - { - history.replaceState({},this.innerText,targetAnchorHREF); - $(this).addClass("active"); - var sidebarOffset = (sidebarBottom > 200) ? 200 : headerOffset - 20; - $("#sidebar-wrapper").animate({ - scrollTop: $("#sidebar-wrapper").scrollTop() + $(this).position().top - sidebarOffset - },100); - //document.getElementById("sidebar-wrapper").scrollTop = this.getBoundingClientRect().top - 200; - } else { - $(this).removeClass("active"); + $(this).removeClass("active"); + }); + $("#sidebar-wrapper").animate({ + scrollTop: 0 + },800); + } else { + var targetAnchorHREF = document.location.protocol +"//"+ document.location.hostname + (location.port ? ':'+location.port: '') + document.location.pathname + "#" + heading; + // make sure we aren't filtering out that heading level + var noFilterFound = false; + $("#my_toc a").each(function(){ + if (this.href==targetAnchorHREF) { + noFilterFound = true; } }); + // now, highlight that heading + if (noFilterFound) + { + $("#my_toc a").each(function(){ + //console.log("right-nav",this.href); + if (this.href==targetAnchorHREF) + { + history.replaceState({},this.innerText,targetAnchorHREF); + $(this).addClass("active"); + var sidebarOffset = (sidebarBottom > 200) ? 200 : headerOffset - 20; + $("#sidebar-wrapper").animate({ + scrollTop: $("#sidebar-wrapper").scrollTop() + $(this).position().top - sidebarOffset + },100); + //document.getElementById("sidebar-wrapper").scrollTop = this.getBoundingClientRect().top - 200; + } else { + $(this).removeClass("active"); + } + }); + } } } } @@ -243,7 +246,7 @@ $('#switch-style').change(function() { if ($(this).is(':checked')) { applyNight(); createCookie("night",true,999) - } else { + } else { applyDay(); // swapStyleSheet('/css/style.css'); eraseCookie("night") diff --git a/js/menu.js b/js/menu.js index 7146eba63e..2df54452df 100644 --- a/js/menu.js +++ b/js/menu.js @@ -261,18 +261,9 @@ function renderTagsPage() var glossaryOutput = glossary.terms[i].def; } } - if (glossaryOutput) $("#glossaryMatch").html("

Definition of: " + tagToLookup + "

" + glossaryOutput); + if (glossaryOutput) { + $("#glossaryMatch").html("

Definition of: " + tagToLookup + "

" + glossaryOutput); + } renderTopicsByTagTable(tagToLookup,"topicMatch",true); } } - -jQuery(document).ready(function(){ - $.getJSON( "/metadata.txt", function( data ) { - metadata = data; - hookupTOCEvents(); - $.getJSON( "/glossary.txt", function( data ) { - glossary = data; - renderTagsPage(); - }); - }); -});