mirror of https://github.com/Kozea/pygal.git
Florian Mounier
13 years ago
11 changed files with 248 additions and 64 deletions
@ -0,0 +1,57 @@
|
||||
_ = (x) -> document.querySelectorAll(x) |
||||
|
||||
add_class = (e, class_name) -> |
||||
return if not e |
||||
cn = e.getAttribute('class').split(' ') |
||||
if class_name not in cn |
||||
cn.push(class_name) |
||||
e.setAttribute('class', cn.join(' ')) |
||||
|
||||
rm_class = (e, class_name) -> |
||||
return if not e |
||||
cn = e.getAttribute('class').split(' ') |
||||
for cls, i in cn |
||||
if cls == class_name |
||||
cn.splice(i, 1) |
||||
e.setAttribute('class', cn.join(' ')) |
||||
|
||||
|
||||
@svg_load = -> |
||||
for element in _('.reactive-text') |
||||
element.addEventListener('mouseover', ((e) -> |
||||
-> |
||||
add_class(e, 'active') |
||||
add_class(document.getElementById(e.id.replace(/re/, '')), 'active') |
||||
)(element), false) |
||||
element.addEventListener('mouseout', ((e) -> |
||||
-> |
||||
rm_class(e, 'active') |
||||
rm_class(document.getElementById(e.id.replace(/re/, '')), 'active') |
||||
)(element), false) |
||||
for element in _('.reactive') |
||||
element.addEventListener('mouseover', ((e) -> |
||||
-> |
||||
add_class(e, 'active') |
||||
add_class(document.getElementById('re' + e.id), 'active') |
||||
)(element), false) |
||||
element.addEventListener('mouseout', ((e) -> |
||||
-> |
||||
rm_class(e, 'active') |
||||
rm_class(document.getElementById('re' + e.id), 'active') |
||||
)(element), false) |
||||
|
||||
for element in _('.activate-serie') |
||||
element.addEventListener('mouseover', ((e) -> |
||||
-> |
||||
num = e.id.replace('activate-serie-', '') |
||||
for element in _('.serie-' + num + ' .reactive') |
||||
add_class(element, 'active') |
||||
add_class(document.getElementById('re' + element.id), 'active') |
||||
)(element), false) |
||||
element.addEventListener('mouseout', ((e) -> |
||||
-> |
||||
num = e.id.replace('activate-serie-', '') |
||||
for element in _('.serie-' + num + ' .reactive') |
||||
rm_class(element, 'active') |
||||
rm_class(document.getElementById('re' + element.id), 'active') |
||||
)(element), false) |
@ -0,0 +1,99 @@
|
||||
// Generated by CoffeeScript 1.2.1-pre
|
||||
(function() { |
||||
var add_class, rm_class, _, |
||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; |
||||
|
||||
_ = function(x) { |
||||
return document.querySelectorAll(x); |
||||
}; |
||||
|
||||
add_class = function(e, class_name) { |
||||
var cn; |
||||
if (!e) return; |
||||
cn = e.getAttribute('class').split(' '); |
||||
if (__indexOf.call(cn, class_name) < 0) cn.push(class_name); |
||||
return e.setAttribute('class', cn.join(' ')); |
||||
}; |
||||
|
||||
rm_class = function(e, class_name) { |
||||
var cls, cn, i, _i, _len; |
||||
if (!e) return; |
||||
cn = e.getAttribute('class').split(' '); |
||||
for (i = _i = 0, _len = cn.length; _i < _len; i = ++_i) { |
||||
cls = cn[i]; |
||||
if (cls === class_name) cn.splice(i, 1); |
||||
} |
||||
return e.setAttribute('class', cn.join(' ')); |
||||
}; |
||||
|
||||
this.svg_load = function() { |
||||
var element, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _results; |
||||
_ref = _('.reactive-text'); |
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
||||
element = _ref[_i]; |
||||
element.addEventListener('mouseover', (function(e) { |
||||
return function() { |
||||
add_class(e, 'active'); |
||||
return add_class(document.getElementById(e.id.replace(/re/, '')), 'active'); |
||||
}; |
||||
})(element), false); |
||||
element.addEventListener('mouseout', (function(e) { |
||||
return function() { |
||||
rm_class(e, 'active'); |
||||
return rm_class(document.getElementById(e.id.replace(/re/, '')), 'active'); |
||||
}; |
||||
})(element), false); |
||||
} |
||||
_ref2 = _('.reactive'); |
||||
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { |
||||
element = _ref2[_j]; |
||||
element.addEventListener('mouseover', (function(e) { |
||||
return function() { |
||||
add_class(e, 'active'); |
||||
return add_class(document.getElementById('re' + e.id), 'active'); |
||||
}; |
||||
})(element), false); |
||||
element.addEventListener('mouseout', (function(e) { |
||||
return function() { |
||||
rm_class(e, 'active'); |
||||
return rm_class(document.getElementById('re' + e.id), 'active'); |
||||
}; |
||||
})(element), false); |
||||
} |
||||
_ref3 = _('.activate-serie'); |
||||
_results = []; |
||||
for (_k = 0, _len3 = _ref3.length; _k < _len3; _k++) { |
||||
element = _ref3[_k]; |
||||
element.addEventListener('mouseover', (function(e) { |
||||
return function() { |
||||
var element, num, _l, _len4, _ref4, _results2; |
||||
num = e.id.replace('activate-serie-', ''); |
||||
_ref4 = _('.serie-' + num + ' .reactive'); |
||||
_results2 = []; |
||||
for (_l = 0, _len4 = _ref4.length; _l < _len4; _l++) { |
||||
element = _ref4[_l]; |
||||
add_class(element, 'active'); |
||||
_results2.push(add_class(document.getElementById('re' + element.id), 'active')); |
||||
} |
||||
return _results2; |
||||
}; |
||||
})(element), false); |
||||
_results.push(element.addEventListener('mouseout', (function(e) { |
||||
return function() { |
||||
var element, num, _l, _len4, _ref4, _results2; |
||||
num = e.id.replace('activate-serie-', ''); |
||||
_ref4 = _('.serie-' + num + ' .reactive'); |
||||
_results2 = []; |
||||
for (_l = 0, _len4 = _ref4.length; _l < _len4; _l++) { |
||||
element = _ref4[_l]; |
||||
rm_class(element, 'active'); |
||||
_results2.push(rm_class(document.getElementById('re' + element.id), 'active')); |
||||
} |
||||
return _results2; |
||||
}; |
||||
})(element), false)); |
||||
} |
||||
return _results; |
||||
}; |
||||
|
||||
}).call(this); |
Loading…
Reference in new issue