Minor changes to toggling

master
Addy Osmani 2014-06-19 14:56:27 +01:00
parent 951c1fe1ab
commit 0cecead44b
1 changed files with 7 additions and 4 deletions

View File

@ -1165,16 +1165,19 @@
'use strict'; 'use strict';
var snippetToggle = document.querySelector('#snippet-toggle'); var snippetToggle = document.querySelector('#snippet-toggle');
var snippets;
snippetToggle.addEventListener('click', function() { snippetToggle.addEventListener('click', function() {
var snippets = document.querySelectorAll('.auto-gen-code-snippet'); if(snippets){
for(var i = 0; i < snippets.length; i++) { for(var i = 0; i < snippets.length; i++) {
snippets[i].classList.toggle('auto-gen-code-visible'); snippets[i].classList.toggle('auto-gen-code-visible');
}; };
}
}, true); }, true);
window.onload = function() { window.onload = function() {
createCodeSamples(); createCodeSamples();
snippets = document.querySelectorAll('.auto-gen-code-snippet');
} }
function createCodeSamples() { function createCodeSamples() {