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

Improve nav buttons in html output, bump version. #92

Merged
merged 1 commit into from
May 26, 2017
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
2 changes: 1 addition & 1 deletion lib/adiwg/mdtranslator/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
module ADIWG
module Mdtranslator
# current mdtranslator version
VERSION = "2.0.0rc6"
VERSION = "2.0.0rc7"
end
end

Expand Down
15 changes: 14 additions & 1 deletion lib/adiwg/mdtranslator/writers/html/sections/html_bodyScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ if (!Array.prototype.forEach) {
function openDetail(evt) {
var href = evt.target.getAttribute("href");
href = href.slice(1);

if(window.frameElement){
evt.preventDefault();
var el = document.getElementById(href);
window.scrollTo(0, el.offsetTop);
}
var parentNode = document.getElementById(href).parentNode;
parentNode.open = true;
}
Expand Down Expand Up @@ -58,7 +64,14 @@ function closeAllDetails() {
var navBtnList = document.querySelectorAll('a.navBtn');
var navBtnArray = Array.prototype.slice.call(navBtnList);
navBtnArray.forEach(function(btn, btnIdx, btnArr) {
btn.addEventListener("click", openDetail, false);
var href = btn.getAttribute("href").slice(1);
var target = document.getElementById(href);
//hide button if target is not present
if(target) {
btn.addEventListener("click", openDetail, false);
} else {
btn.style.display = 'none';
}
});

// add event listener to openAllButton
Expand Down