1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 06:04:53 +00:00

Update Daux theme using custom changes for now

This commit is contained in:
J. King 2019-08-22 13:30:10 -04:00
parent a24bfa0683
commit 2c1dcdcd6d
5 changed files with 48 additions and 40 deletions

File diff suppressed because one or more lines are too long

View file

@ -107,64 +107,57 @@ if (hljs) {
}; };
}; };
var navItems = document.querySelectorAll('.Nav__item.has-children > a'); var navItems = document.querySelectorAll('.Nav__item.has-children i.Nav__arrow');
function _toggleSubMenu(ev) { function _toggleSubMenu(ev) {
if (ev.preventDefault !== undefined) { if (ev.preventDefault !== undefined) {
ev.preventDefault(); ev.preventDefault();
} }
var parent = ev.target.parentNode; var parent = ev.target.parentNode.parentNode;
var subNav = parent.querySelector('ul.Nav'); var subNav = parent.querySelector('ul.Nav');
if (ev.preventDefault !== undefined && parent.classList.contains('Nav__item--open')) { if (ev.preventDefault !== undefined && parent.classList.contains('Nav__item--open')) {
subNav.style.height = 0; // 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'); parent.classList.remove('Nav__item--open');
} else { } else {
if (ev.preventDefault !== undefined) { if (ev.preventDefault !== undefined) {
subNav.style.transitionDuration = Math.max(subNav.scrollHeight, 150) + 'ms'; 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'; subNav.style.height = subNav.scrollHeight + 'px';
parent.classList.add('Nav__item--open'); parent.classList.add('Nav__item--open');
} else { } else {
// When running at page load the transitions don't need to fire and // When running at page load the transitions don't need to fire and
// the classList doesn't need to be altered. // the classList doesn't need to be altered.
subNav.style.transitionDuration = '0ms'; subNav.style.height = 'auto';
subNav.style.height = subNav.scrollHeight + 'px';
subNav.style.transitionDuration = Math.max(subNav.scrollHeight, 150) + 'ms';
} }
} }
} }
// Because font sizes change the height of the menus can change so they must function _setHeightToAuto(ev) {
// be recalculated if necessary when the viewport size changes. if (ev.target.style.height !== '0px') {
function _resize() { ev.target.style.height = 'auto';
var subNav = document.querySelector('.Nav .Nav'),
height, cur;
for (var i = 0; i < subNav.length; i++) {
cur = subNav[i];
height = parseFloat(cur.style.height, 10);
if (height > 0 && cur.scrollHeight !== height) {
// Transitions don't need to fire when resizing the window.
cur.style.transitionDuration = '0ms';
cur.style.height = cur.scrollHeight + 'px';
cur.style.transitionDuration = Math.max(cur.scrollHeight, 150) + 'ms';
}
}
} }
for (var i = 0, cur; i < navItems.length; i++) { 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 = navItems[i];
cur.addEventListener('click', _toggleSubMenu); cur.addEventListener('click', _toggleSubMenu);
if (cur.parentNode.classList.contains('Nav__item--open')) { if (cur.parentNode.parentNode.classList.contains('Nav__item--open')) {
_toggleSubMenu({ target: cur }); _toggleSubMenu({ target: cur });
} }
} }
window.addEventListener('resize', debounce(_resize, 150));
window.addEventListener('orientationchange', _resize);
})(); })();
(function() { (function() {

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,11 @@
{ {
"repositories": [
{
"type": "vcs",
"url": "https://github.com/mensbeam/daux.io/"
}
],
"require": { "require": {
"daux/daux.io": "*" "daux/daux.io": "dev-sans-jquery"
} }
} }

View file

@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "18f1867fdb8b951d62546b63f535d837", "content-hash": "42b5c476c1c8044c78bad07aa023a824",
"packages": [ "packages": [
{ {
"name": "daux/daux.io", "name": "daux/daux.io",
"version": "0.10.0", "version": "dev-sans-jquery",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/dauxio/daux.io.git", "url": "https://github.com/mensbeam/daux.io.git",
"reference": "5a19258651d5ff7d4079eda09faa537626b28420" "reference": "7e45ef7f0040f0cabd2bd6792b074b2e9a629db0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/dauxio/daux.io/zipball/5a19258651d5ff7d4079eda09faa537626b28420", "url": "https://api.github.com/repos/mensbeam/daux.io/zipball/7e45ef7f0040f0cabd2bd6792b074b2e9a629db0",
"reference": "5a19258651d5ff7d4079eda09faa537626b28420", "reference": "7e45ef7f0040f0cabd2bd6792b074b2e9a629db0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -52,7 +52,11 @@
"Todaymade\\Daux\\": "libs/" "Todaymade\\Daux\\": "libs/"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "scripts": {
"test": [
"phpunit"
]
},
"license": [ "license": [
"MIT" "MIT"
], ],
@ -74,7 +78,10 @@
"markdown", "markdown",
"md" "md"
], ],
"time": "2019-08-13T09:20:39+00:00" "support": {
"source": "https://github.com/mensbeam/daux.io/tree/sans-jquery"
},
"time": "2019-08-17T01:08:58+00:00"
}, },
{ {
"name": "guzzlehttp/guzzle", "name": "guzzlehttp/guzzle",
@ -1485,7 +1492,9 @@
"packages-dev": [], "packages-dev": [],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": {
"daux/daux.io": 20
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": [],