Skip to content
Browse files

Fix a selector bug.

  • Loading branch information...
1 parent e7e6b2c commit 539222daf4dac96f2fa5eaae9d3dc40ef8866548 @rnons committed Jul 19, 2014
Showing with 12 additions and 7 deletions.
  1. +12 −7 templates/talks.julius
View
19 templates/talks.julius
@@ -3,32 +3,37 @@
var selected = [],
main = document.querySelector('#main'),
+ langs = document.querySelectorAll('#main li'),
watch = document.querySelector('#watch'),
download = document.querySelector('.download'),
en = document.querySelector('[data-lang="en"]');
var mkUrl = function(arr) {
if (arr.length === 0) return '&lang=en';
- else return arr.map(function(i){return '&lang=' + i}).join('');
+ else return arr.map(function(i){return '&lang=' + i;}).join('');
};
if (en) {
en.classList.add('selected');
selected.push('en');
}
- main.addEventListener('click', function(e) {
+ var selectLang = function(e) {
var lang = e.target.dataset.lang,
len = selected.length,
index = selected.indexOf(lang);
if (len < 2) {
- e.target.classList.toggle('selected');
- index === -1 ? selected.push(lang) : selected.splice(index, 1);
+ e.target.classList.toggle('selected');
+ index === -1 ? selected.push(lang) : selected.splice(index, 1);
} else if (len === 2) {
- e.target.classList.remove('selected');
- if (index !== -1) selected.splice(index, 1);
+ e.target.classList.remove('selected');
+ if (index !== -1) selected.splice(index, 1);
}
- });
+ };
+
+ for(var index=0; index<langs.length; index++) {
+ langs[index].addEventListener('click', selectLang);
+ }
if (download) {
download.addEventListener('click', function(e) {

0 comments on commit 539222d

Please sign in to comment.
Something went wrong with that request. Please try again.