Mercurial > hg > isophonics-drupal-site
comparison core/themes/seven/js/mobile.install.es6.js @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 (function () { | |
2 function findActiveStep(steps) { | |
3 for (let i = 0; i < steps.length; i++) { | |
4 if (steps[i].className === 'is-active') { | |
5 return i + 1; | |
6 } | |
7 } | |
8 // The final "Finished" step is never "active". | |
9 if (steps[steps.length - 1].className === 'done') { | |
10 return steps.length; | |
11 } | |
12 return 0; | |
13 } | |
14 | |
15 function installStepsSetup() { | |
16 const steps = document.querySelectorAll('.task-list li'); | |
17 if (steps.length) { | |
18 const header = document.querySelector('header[role="banner"]'); | |
19 const stepIndicator = document.createElement('div'); | |
20 stepIndicator.className = 'step-indicator'; | |
21 stepIndicator.innerHTML = `${findActiveStep(steps)}/${steps.length}`; | |
22 header.appendChild(stepIndicator); | |
23 } | |
24 } | |
25 | |
26 if (document.addEventListener) { | |
27 document.addEventListener('DOMContentLoaded', installStepsSetup); | |
28 } | |
29 }()); |