forked from rism-digital/verovio.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopic06.html
76 lines (63 loc) · 2.62 KB
/
topic06.html
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
70
71
72
73
74
75
76
---
next_text: Interacting with editorial choices
next_id: topic07
---
<h3>Selecting readings</h3>
<p>
Verovio supports variant readings with <code><app></code> and <code><rdg></code>/<code><lem></code> elements. During the rendering, only the <code><lem></code> (or the first <code><rdg></code> if none is provided) is rendered.
</p>
<p>
In this example we can see how <code><app></code> children can be highlighted and how it is possible to switch to another variant. For this, we use an <code>appXPath</code> variable that is passed to the toolkit as <code>appXPathQuery</code> option.
</p>
{% highlight javascript %}
///////////////////////////////////////////////////
/* A variable for selecting the <rdg> in a <app> */
///////////////////////////////////////////////////
var appXPath = [];
options = {
pageHeight: pageHeight,
pageWidth: pageWidth,
scale: zoom,
adjustPageHeight: true,
appXPathQuery: appXPath
};
vrvToolkit.setOptions(options);
{% endhighlight %}
<p>
In this example, we switch from one variant to another by pressing 1 (the lemma) and 2 (the source '#source.1570'). Of course, any other selection input would be possible.
</p>
<p>
Because the variant selection is performed when loading the file into Verovio, changing a variant selection requires the file to be relaoded. For this reason, we call <code>loadFile()</code> (and not <code>loadPage()</code>) when having change the variant selection.
</p>
{% highlight javascript %}
//////////////////////////////////////////
/* Key events for switching the reading */
//////////////////////////////////////////
if (event.keyCode == 49) {
appXPath = [];
loadFile();
}
else if (event.keyCode == 50) {
appXPath = ["./rdg[contains(@source, '#source.1570')]"];
loadFile();
}
{% endhighlight %}
<p>
We can easily highlight lemma or readings using the selector as seen in the tutorial about highlighting.
</p>
{% highlight javascript %}
///////////////////////////////////////////////////
/* Highlights the lem in blue and the rdg in red */
///////////////////////////////////////////////////
$(".lem").attr("fill", "#00e").attr("stroke", "#00e");
$(".rdg").attr("fill", "#d00").attr("stroke", "#d00");
{% endhighlight %}
{% include html-tutorial.html id="code1" file="topic06-apparatus.html" %}
<div id="code1-xml" style="display: none">
{% highlight html %}
{% include_relative gh-tutorial/topic06-apparatus.html %}
{% endhighlight %}
</div>
<div class="pull-right">
<p><a href="./tutorial.xhtml?id={{ page.next_id }}">{{ page.next_text }}</a> →</p>
</div>