Created
August 20, 2014 07:48
-
-
Save mildfuzz/84fc7a84a41b35c7ea9e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //styles form padding offset | |
| (function() { | |
| var offset, $input, spanWidth, | |
| $inputs = document.getElementsByClassName('input-wrapper'); | |
| for(var i = 0; i < $inputs.length; i++) { | |
| spanWidth = Math.round($inputs[i].childNodes[0].getBoundingClientRect().width); | |
| inoutTextOffset = (spanWidth + 7) + 'px'; | |
| $input = $inputs[i].childNodes[1]; | |
| $input.style.paddingLeft = inoutTextOffset; | |
| } | |
| })(); | |
| //week menu | |
| (function assignDropDowns(){ | |
| var $this, listHeight, subjectHeight, | |
| offset = 10, | |
| $subjects = document.getElementsByClassName('subject'); | |
| for (var i = 0; i < $subjects.length; i++) { | |
| $subject = $subjects[i]; | |
| $subject.style.height = $subject.childNodes[1].getBoundingClientRect().height + 27 + 'px'; | |
| subjectHeight = $subject.childNodes[1].getBoundingClientRect().height + 27; | |
| listHeight = $subject.children[1].getBoundingClientRect().height; | |
| $subject.dataset.fullHeight = listHeight + subjectHeight + offset; | |
| $subject.dataset.startHeight = subjectHeight; | |
| $subject.style.height = $subject.childNodes[1].getBoundingClientRect().height + 27 + 'px'; | |
| function clickEvent(e) { | |
| var $subject = e.currentTarget; | |
| if ($subject.classList.contains('active')) { | |
| $subject.classList.remove('active'); | |
| $subject.style.height = $subject.dataset.startHeight + 'px'; | |
| } else { | |
| $subject.classList.add('active'); | |
| $subject.style.height = $subject.dataset.fullHeight + 'px'; | |
| } | |
| } | |
| $subject.onclick = clickEvent; | |
| $subject.classList.remove('active'); | |
| } | |
| window.addEventListener('resize',assignDropDowns); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment