-
Notifications
You must be signed in to change notification settings - Fork 1
/
GChordPosition.js
69 lines (68 loc) · 2.17 KB
/
GChordPosition.js
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
67
68
69
GComp.GChordPosition = function(stringNumber, caseNumber) {
this.stringNumber = stringNumber || 1;
this.caseNumber = caseNumber || 0;
var containerDiv = document.createElement('div');
Element.addClassName(containerDiv, 'case');
var stringDiv = document.createElement('div');
Element.addClassName(stringDiv, 'string');
containerDiv.appendChild(stringDiv);
this.domEl = containerDiv;
this.domElCase = containerDiv;
this.domElString = stringDiv;
this.bindEvents();
this.enable();
}
GComp.GChordPosition.prototype = new GComp.GView;
GComp.GChordPosition.prototype.stringNumber = null;
GComp.GChordPosition.prototype.caseNumber = null;
GComp.GChordPosition.prototype.finger = 5;
GComp.GChordPosition.prototype.possibleFingers = {
1: 'index',
2: 'majeur',
3: 'annulaire',
4: 'auriculaire',
5: 'thumb'
};
GComp.GChordPosition.prototype.enabled = false;
GComp.GChordPosition.prototype.bindEvents = function() {
this.bind('mouseover', function(evt, model) {
model.highlight();
});
this.bind('mouseout', function(evt, model) {
model.lowlight();
});
this.bind('click', function(evt, model) {
model.toggle();
model.flash();
});
};
GComp.GChordPosition.prototype.draw = function(divEl) {
divEl.appendChild(this.domEl);
}
GComp.GChordPosition.prototype.toggle = function() {
this.enabled = !this.enabled;
Element.toggleClassName(this.domElCase, 'active');
}
GComp.GChordPosition.prototype.enable = function() {
this.enabled = true;
Element.addClassName(this.domElCase, 'active');
}
GComp.GChordPosition.prototype.disable = function() {
this.enabled = false;
Element.removeClassName(this.domElCase, 'active');
}
GComp.GChordPosition.prototype.isEnabled = function() {
return this.enabled;
}
/**
* @param Note
*/
GComp.GChordPosition.prototype.getNote = function(stringNote) {
// FIXME
// if (!stringNote)
// throw new Exception('Please give a GComp.Note specifying the note of the string corresponding to the position');
var note = new GComp.Note();
var noteIndex = stringNote.noteIndex + this.caseNumber;
note.noteIndex = noteIndex;
return note;
}