Skip to content

Instantly share code, notes, and snippets.

@m4tm4t
Created October 31, 2013 16:02
Show Gist options
  • Save m4tm4t/7252234 to your computer and use it in GitHub Desktop.
Save m4tm4t/7252234 to your computer and use it in GitHub Desktop.
/*
* 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