Skip to content

Commit

Permalink
Fix docs js
Browse files Browse the repository at this point in the history
  • Loading branch information
David van Leeuwen committed Apr 18, 2016
1 parent 8c2405b commit adf56fe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
3 changes: 0 additions & 3 deletions layouts/docs.jade
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,4 @@ html
inputSelector: '.docs-search__input'
});

script(src='/scripts/main.js')
script(src='/scripts/docs.js')
script(src='/scripts/overlay.js')
script(src='//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-570558ee2719a9f0')
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"metalsmith": "^2.1.0",
"metalsmith-babel": "^4.0.0",
"metalsmith-browser-sync": "davidvanleeuwen/metalsmith-browser-sync",
"metalsmith-changed": "^0.2.0",
"metalsmith-copy": "^0.2.1",
"metalsmith-each": "^0.1.1",
"metalsmith-jade": "davidvanleeuwen/metalsmith-jade",
Expand Down
25 changes: 12 additions & 13 deletions src/scripts/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,28 @@

// Navigation
Array.prototype.forEach.call($('.docs-nav__item_folder a'), el => {
el.on('click', function(e) {
docsMenu.style.maxHeight = null; // remove max-height set by mobile docs menu
$(el).on('click', function(e) {
docsMenu.css('maxHeight', null); // remove max-height set by mobile docs menu

if(e.currentTarget.hasClass('docs-nav__item__arrow')) e.preventDefault();
else if(!e.currentTarget.getAttribute('data-path')) return;
let parent = e.currentTarget.parentNode.parentNode;
let img = e.currentTarget.find('img');
if($(e.currentTarget).hasClass('docs-nav__item__arrow')) e.preventDefault();
else if(!$(e.currentTarget).attr('data-path')) return;

let parent = $($(e.currentTarget).parent().parent());
let img = $($(e.currentTarget).find('img'));

parent.hasClass('docs-nav__item--closed') ? parent.removeClass('docs-nav__item--closed') : parent.addClass('docs-nav__item--closed')
if(parent.hasClass('docs-nav__item--closed')) {
parent.find('.docs-nav__item__title').hasClass('active') ? img.attr('src', '/assets/images/icons/arrow-right-docs-selected.svg') : img.attr('src', '/assets/images/icons/arrow-right-docs.svg');
$(parent.find('.docs-nav__item__title')).hasClass('active') ? img.attr('src', '/assets/images/icons/arrow-right-docs-selected.svg') : img.attr('src', '/assets/images/icons/arrow-right-docs.svg');
} else {
parent.find('.docs-nav__item__title').hasClass('active') ? img.attr('src', '/assets/images/icons/arrow-down-docs.svg') : img.attr('src', '/assets/images/icons/arrow-down-docs-unselected.svg');
$(parent.find('.docs-nav__item__title')).hasClass('active') ? img.attr('src', '/assets/images/icons/arrow-down-docs.svg') : img.attr('src', '/assets/images/icons/arrow-down-docs-unselected.svg');
}

Stickyfill.rebuild();
});
});

// Mobile docs menu
let mobileDocsMenu = $('.docs-menu-mobile');
let docsMenu = mobileDocsMenu.find('.docs-menu-mobile-container');
let docsMenuButton = mobileDocsMenu.find('.open-docs-menu');
let docsMenu = $(mobileDocsMenu.find('.docs-menu-mobile-container'));
let docsMenuButton = $(mobileDocsMenu.find('.open-docs-menu'));
let docsMenuHeight;
let docsMenuActive;

Expand Down Expand Up @@ -76,7 +75,7 @@

// Feedback
Array.prototype.forEach.call($('#submit-feedback'), el => {
el.href = `https://github.com/dcos/dcos-docs/issues/new?body=${encodeURI(window.location.href)}`;
$(el).href = `https://github.com/dcos/dcos-docs/issues/new?body=${encodeURI(window.location.href)}`;
});

})()

0 comments on commit adf56fe

Please sign in to comment.