Clone of official tools
Diff: ci_templates/scripts.js
- Revision:
- 36:96847d42f010
- Parent:
- 35:da9c89f8be7d
- Child:
- 37:f8cfeb185c30
--- a/ci_templates/scripts.js Wed Feb 15 13:53:18 2017 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -<script> - var elements = document.querySelectorAll(".toggleshow"), - hideClass = 'toggleshow-hide'; - - for (var i = 0; i < elements.length; i++) { - var arrow = elements[i].querySelector(".toggleshow-arrow"); - // Initial hide/show based on class - // Update arrow as well - if (containsClass(elements[i], 'toggleshow-hide')) { - toggleDisplay(elements[i]); - changeArrow(arrow, false); - } else { - changeArrow(arrow, true); - } - - // Add click handler - addClick(elements[i], toggleDisplay); - } - - function containsClass(element, className) { - var eleClassName = ' ' + elements[i].className + ' '; - return eleClassName.indexOf(' ' + className + ' ') > -1; - } - - function toggleDisplay(parentElement) { - var body = parentElement.querySelector(".toggleshow-body"), - arrow = parentElement.querySelector(".toggleshow-arrow"); - - if (body.style.display == 'block' || body.style.display == '') { - body.style.display = 'none'; - changeArrow(arrow, false); - } else { - body.style.display = 'block'; - changeArrow(arrow, true); - } - } - - function changeArrow(element, visible) { - if (visible) { - element.innerHTML = '▲'; - } else { - element.innerHTML = '▼'; - } - } - - function addClick(parentElement, func) { - parentElement.querySelector(".toggleshow-title").addEventListener("click", function(e) { - func(parentElement); - e.preventDefault(); - return false; - }); - } -</script>