index.js
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var inherits = require('inherits');
var EventEmitter = require('events').EventEmitter;
var infoScreenTpl = require('./info-screen.html');
require('./info-screen.scss');
function InfoScreen() {
this.visible = false;
}
inherits(InfoScreen, EventEmitter);
InfoScreen.prototype.load = function (element) {
this.element = element;
this.element.innerHTML = infoScreenTpl;
this.element.classList.add('info-screen');
var main = this.element.querySelector('#info-main');
var realizadores = this.element.querySelector('#info-realizadores');
var left = this.element.querySelector('.arrow-left');
var right = this.element.querySelector('.arrow-right');
var bullets = this.element.querySelectorAll('.info-bullet');
left.addEventListener('click', function() {
realizadores.classList.remove('active');
main.classList.add('active');
this.classList.remove('active');
right.classList.add('active');
bullets[1].classList.remove('active');
bullets[0].classList.add('active');
});
right.addEventListener('click', function() {
main.classList.remove('active');
realizadores.classList.add('active');
this.classList.remove('active');
left.classList.add('active');
bullets[0].classList.remove('active');
bullets[1].classList.add('active');
});
this.hide();
};
InfoScreen.prototype.toggle = function () {
if (this.visible) this.hide();
else this.show();
};
InfoScreen.prototype.hide = function () {
this.visible = false;
this.element.classList.remove('active');
this.emit('hide');
};
InfoScreen.prototype.show = function () {
this.visible = true;
this.element.classList.add('active');
this.emit('show');
};
module.exports = InfoScreen;