Created
October 31, 2013 16:02
-
-
Save m4tm4t/7252234 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* CSS Editor | |
* Author: robard_m | |
*/ | |
// Page load event | |
window.addEventListener('load', function load(event) { | |
window.removeEventListener('load', load, false); | |
CSSeditor.init(); | |
}); | |
var CSSeditor = { | |
init: function() { | |
console.log('Initializing CSS Editor'); | |
mainNav = document.getElementById('mainNav'); | |
subNavs = mainNav.getElementsByClassName('subNav'); | |
for (var i = subNavs.length - 1; i >= 0; i--) { | |
subNav = subNavs[i]; | |
subNav.style.display = 'none' | |
link = subNav.previousElementSibling; | |
subNavLinks = subNav.getElementsByTagName('a'); | |
for (var ii = subNavLinks.length - 1; ii >= 0; ii--) { | |
subNavLink = subNavLinks[ii]; | |
subNavLink.addEventListener('click', function click(event) { | |
event.preventDefault() | |
document.getElementById('content').innerHTML = this.innerHTML; | |
}); | |
}; | |
link.addEventListener('click', function click(event) { | |
subNav = this.nextElementSibling | |
event.preventDefault() | |
if (subNav.style.display == 'none') { | |
subNav.style.display = 'block'; | |
document.getElementById('content').innerHTML = this.innerHTML | |
} | |
else { | |
subNav.style.display = 'none'; | |
} | |
}); | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment