-
Notifications
You must be signed in to change notification settings - Fork 0
/
tengwar-explainer.js
59 lines (53 loc) · 2.07 KB
/
tengwar-explainer.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
"use strict";
module.exports = TengwarEditor;
var modes = require("tengwar/modes");
var fonts = require("tengwar/fonts");
function TengwarEditor() {
}
function from(value) {
if (value) {
if (value.from) {
return value.from.toUpperCase();
}
}
}
TengwarEditor.prototype.hookup = function (id, component, scope) {
var components = scope.components;
if (id === "this") {
this.sections = components.sections;
} else if (id === "sections:iteration") {
components.paragraphs.value = component.value;
} else if (id === "paragraphs:iteration") {
components.lines.value = component.value;
} else if (id === "lines:iteration") {
components.words.value = component.value;
components.lineBreak.value = component.index !== components.lines.value.length - 1;
} else if (id === "words:iteration") {
components.columns.value = component.value;
components.wordBreak.value = component.index !== components.words.value.length - 1;
} else if (id === "columns:iteration") {
components.tengwar.value = this.font.transcribeColumn(component.value);
components.tengwarContainer.className = "tengwar rendered " + this.fontName;
components.tildeAbove.value = from(component.value.tildeAboveNote);
components.above.value = from(component.value.aboveNote);
components.tengwa.value = from(component.value.tengwaNote);
components.below.value = from(component.value.belowNote);
components.tildeBelow.value = from(component.value.tildeBelowNote);
components.following.value = from(component.value.followingNote);
}
};
Object.defineProperty(TengwarEditor.prototype, "value", {
set: function (value) {
var mode = modes[value.mode];
var font = fonts[value.font];
var options = {
font: font,
language: value.language,
block: true
};
this.font = font;
this.fontName = value.font;
this.mode = mode;
this.sections.value = mode.parse(value.value, options);
}
});