J. King
5 years ago
10 changed files with 129 additions and 304 deletions
File diff suppressed because one or more lines are too long
@ -1,182 +0,0 @@ |
|||
/** global localStorage, hljs */ |
|||
|
|||
if (hljs) { |
|||
hljs.initHighlightingOnLoad(); |
|||
} |
|||
|
|||
(function() { |
|||
var codeBlocks = document.querySelectorAll(".s-content pre"); |
|||
var toggleCodeSection = document.querySelector(".CodeToggler"); |
|||
if (!toggleCodeSection) { |
|||
return; |
|||
} else if (!codeBlocks.length) { |
|||
toggleCodeSection.classList.add("Hidden"); |
|||
return; |
|||
} |
|||
|
|||
var toggleCodeBlockBtnList = toggleCodeSection.querySelectorAll(".CodeToggler__button"); |
|||
var toggleCodeBlockBtnSet = toggleCodeSection.querySelector(".CodeToggler__button--main"); // available when floating is disabled
|
|||
var toggleCodeBlockBtnHide = toggleCodeSection.querySelector(".CodeToggler__button--hide"); |
|||
var toggleCodeBlockBtnBelow = toggleCodeSection.querySelector(".CodeToggler__button--below"); |
|||
var toggleCodeBlockBtnFloat = toggleCodeSection.querySelector(".CodeToggler__button--float"); |
|||
var codeBlockView = document.querySelector(".Columns__right"); |
|||
var floating = document.body.classList.contains("with-float"); |
|||
|
|||
function setCodeBlockStyle(codeBlockState) { |
|||
for (var a = 0; a < toggleCodeBlockBtnList.length; a++) { |
|||
toggleCodeBlockBtnList[a].classList.remove("Button--active"); |
|||
} |
|||
switch (codeBlockState) { |
|||
case true: // Show code blocks below (flowed); checkbox
|
|||
var hidden = false; |
|||
break; |
|||
case false: // Hidden code blocks; checkbox
|
|||
var hidden = true; |
|||
break; |
|||
case 2: // Show code blocks inline (floated)
|
|||
toggleCodeBlockBtnFloat.classList.add("Button--active"); |
|||
codeBlockView.classList.add("Columns__right--float"); |
|||
codeBlockView.classList.remove("Columns__right--full"); |
|||
var hidden = false; |
|||
break; |
|||
case 1: // Show code blocks below (flowed)
|
|||
case "checked": |
|||
toggleCodeBlockBtnBelow.classList.add("Button--active"); |
|||
codeBlockView.classList.remove("Columns__right--float"); |
|||
codeBlockView.classList.add("Columns__right--full"); |
|||
var hidden = false; |
|||
break; |
|||
case 0: // Hidden code blocks
|
|||
default: |
|||
toggleCodeBlockBtnHide.classList.add("Button--active"); |
|||
codeBlockView.classList.remove("Columns__right--float"); |
|||
codeBlockView.classList.add("Columns__right--full"); |
|||
var hidden = true; |
|||
break; |
|||
} |
|||
for (var a = 0; a < codeBlocks.length; a++) { |
|||
if (hidden) { |
|||
codeBlocks[a].classList.add("Hidden"); |
|||
} else { |
|||
codeBlocks[a].classList.remove("Hidden"); |
|||
} |
|||
} |
|||
try { |
|||
localStorage.setItem("codeBlockState", +codeBlockState); |
|||
} catch (e) { |
|||
// local storage operations can fail with the file:// protocol
|
|||
} |
|||
} |
|||
if (!floating) { |
|||
toggleCodeBlockBtnSet.addEventListener("change", function(ev) {setCodeBlockStyle(ev.target.checked);}, false); |
|||
} else { |
|||
toggleCodeBlockBtnHide.addEventListener("click", function() {setCodeBlockStyle(0);}, false); |
|||
toggleCodeBlockBtnBelow.addEventListener("click", function() {setCodeBlockStyle(1);}, false); |
|||
toggleCodeBlockBtnFloat.addEventListener("click", function() {setCodeBlockStyle(2);}, false); |
|||
} |
|||
|
|||
try { |
|||
var codeBlockState = localStorage.getItem("codeBlockState"); |
|||
} catch (e) { |
|||
// local storage operations can fail with the file:// protocol
|
|||
var codeBlockState = null; |
|||
} |
|||
if (!codeBlockState) { |
|||
codeBlockState = floating ? 2 : 1; |
|||
} else { |
|||
codeBlockState = parseInt(codeBlockState); |
|||
} |
|||
if (!floating) { |
|||
codeBlockState = !!codeBlockState; |
|||
} |
|||
|
|||
setCodeBlockStyle(codeBlockState); |
|||
})(); |
|||
|
|||
(function() { |
|||
function debounce(func, wait) { |
|||
var timeout; |
|||
return function() { |
|||
var context = this, args = arguments; |
|||
var later = function() { |
|||
timeout = null; |
|||
}; |
|||
|
|||
clearTimeout(timeout); |
|||
timeout = setTimeout(later, wait); |
|||
}; |
|||
}; |
|||
|
|||
var navItems = document.querySelectorAll('.Nav__item.has-children i.Nav__arrow'); |
|||
|
|||
function _toggleSubMenu(ev) { |
|||
if (ev.preventDefault !== undefined) { |
|||
ev.preventDefault(); |
|||
} |
|||
|
|||
var parent = ev.target.parentNode.parentNode; |
|||
var subNav = parent.querySelector('ul.Nav'); |
|||
|
|||
if (ev.preventDefault !== undefined && parent.classList.contains('Nav__item--open')) { |
|||
// Temporarily set the height so the transition can work.
|
|||
subNav.style.height = subNav.scrollHeight + 'px'; |
|||
subNav.style.transitionDuration = Math.max(subNav.scrollHeight, 150) + 'ms'; |
|||
subNav.style.height = '0px'; |
|||
parent.classList.remove('Nav__item--open'); |
|||
} else { |
|||
if (ev.preventDefault !== undefined) { |
|||
subNav.style.transitionDuration = Math.max(subNav.scrollHeight, 150) + 'ms'; |
|||
// After the transition finishes set the height to auto so child
|
|||
// menus can expand properly.
|
|||
subNav.addEventListener('transitionend', _setHeightToAuto); |
|||
subNav.style.height = subNav.scrollHeight + 'px'; |
|||
parent.classList.add('Nav__item--open'); |
|||
} else { |
|||
// When running at page load the transitions don't need to fire and
|
|||
// the classList doesn't need to be altered.
|
|||
subNav.style.height = 'auto'; |
|||
} |
|||
} |
|||
} |
|||
|
|||
function _setHeightToAuto(ev) { |
|||
if (ev.target.style.height !== '0px') { |
|||
ev.target.style.height = 'auto'; |
|||
} |
|||
|
|||
ev.target.removeEventListener('transitionend', _setHeightToAuto); |
|||
} |
|||
|
|||
// Go in reverse here because on page load the child nav items need to be
|
|||
// opened first before their parents so the height on the parents can be
|
|||
// calculated properly.
|
|||
for (var i = navItems.length - 1, cur; i >= 0; i--) { |
|||
cur = navItems[i]; |
|||
cur.addEventListener('click', _toggleSubMenu); |
|||
|
|||
if (cur.parentNode.parentNode.classList.contains('Nav__item--open')) { |
|||
_toggleSubMenu({ target: cur }); |
|||
} |
|||
} |
|||
})(); |
|||
|
|||
(function() { |
|||
var trigger = document.querySelector('.Collapsible__trigger'); |
|||
|
|||
if (!trigger) { |
|||
return; |
|||
} |
|||
|
|||
content = document.querySelector('.Collapsible__content'); |
|||
|
|||
trigger.addEventListener('click', function(ev) { |
|||
if (content.classList.contains('Collapsible__content--open')) { |
|||
content.style.height = 0; |
|||
content.classList.remove('Collapsible__content--open'); |
|||
} else { |
|||
content.style.transitionDuration = Math.max(content.scrollHeight, 150) + 'ms'; |
|||
content.style.height = content.scrollHeight + 'px'; |
|||
content.classList.add('Collapsible__content--open'); |
|||
} |
|||
}); |
|||
})(); |
@ -0,0 +1,2 @@ |
|||
var e=document.querySelectorAll(".s-content pre"),t=document.querySelector(".CodeToggler"),n="daux_code_blocks_hidden";function a(t){for(var a=0;a<e.length;a++)e[a].classList.toggle("Hidden",t);try{localStorage.setItem(n,t)}catch(e){}}t&&(e.length?function(){var e=t.querySelector(".CodeToggler__button--main");e.addEventListener("change",(function(e){a(!e.target.checked)}),!1);var r=!1;try{"false"===(r=localStorage.getItem(n))?r=!1:"true"===r&&(r=!0),r&&(a(!!r),e.checked=!r)}catch(e){}}():t.classList.add("Hidden"));var r=document.querySelector(".Collapsible__trigger");if(r){var o=document.querySelector(".Collapsible__content");r.addEventListener("click",(function(e){o.classList.contains("Collapsible__content--open")?(o.style.height=0,o.classList.remove("Collapsible__content--open"),r.setAttribute("aria-expanded","false")):(r.setAttribute("aria-expanded","true"),o.style.transitionDuration="150ms",o.style.height="".concat(o.scrollHeight,"px"),o.classList.add("Collapsible__content--open"))}))}var l=document.querySelectorAll("pre > code:not(.hljs)");if(l.length){var i=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.async=!0,c.src="".concat(window.base_url,"daux_libraries/highlight.pack.js"),c.onload=function(e){[].forEach.call(l,window.hljs.highlightBlock)},i.appendChild(c)}function s(e){var t=void 0!==e.preventDefault;t&&e.preventDefault();var n=function(e){for(var t=e;(t=t.parentNode)&&9!==t.nodeType;)if(1===t.nodeType&&t.classList.contains("Nav__item"))return t;throw new Error("Could not find a NavItem...")}(e.target),a=n.querySelector("ul.Nav");t&&n.classList.contains("Nav__item--open")?(a.style.height="".concat(a.scrollHeight,"px"),a.style.transitionDuration="150ms",a.style.height="0px",n.classList.remove("Nav__item--open")):t?(a.style.transitionDuration="150ms",a.addEventListener("transitionend",(function e(t){"0px"!==t.target.style.height&&(t.target.style.height="auto"),t.target.removeEventListener("transitionend",e)})),a.style.height="".concat(a.scrollHeight,"px"),n.classList.add("Nav__item--open")):a.style.height="auto"}for(var d,u=document.querySelectorAll(".Nav__item.has-children i.Nav__arrow"),h=u.length-1;h>=0;h--)(d=u[h]).addEventListener("click",s),d.parentNode.parentNode.classList.contains("Nav__item--open")&&s({target:d});var g=document.querySelectorAll(".Nav__item__link--nopage"),v=!0,p=!1,_=void 0;try{for(var y,m=g[Symbol.iterator]();!(v=(y=m.next()).done);v=!0){y.value.addEventListener("click",s)}}catch(e){p=!0,_=e}finally{try{v||null==m.return||m.return()}finally{if(p)throw _}} |
|||
//# sourceMappingURL=daux.min.js.map
|
File diff suppressed because one or more lines are too long
@ -1,5 +1,5 @@ |
|||
{ |
|||
"require": { |
|||
"daux/daux.io": "^0.10.1" |
|||
"daux/daux.io": "^0.11" |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue