forked from perliedman/leaflet-routing-machine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.js
31 lines (28 loc) · 861 Bytes
/
common.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
(function() {
function exampleLinks(current) {
var examples = {
'index.html': 'Basic control',
'styling.html': 'Styling',
'interaction.html': 'Changing interaction'
},
fold = L.DomUtil.get('example-fold'),
list = L.DomUtil.get('examples'),
li,
page;
for (page in examples) {
li = L.DomUtil.create('li', '', list);
if (page !== current) {
li.innerHTML = '<a href="' + page + '">' + examples[page] + '</a>';
} else {
li.innerHTML = examples[page];
}
}
L.DomEvent.addListener(fold, 'click', function() {
var opening = L.DomUtil.hasClass(fold, 'closed');
L.DomUtil[opening ? 'removeClass' : 'addClass'](fold, 'closed');
L.DomUtil[opening ? 'removeClass' : 'addClass'](list, 'hide');
});
}
var m = window.location.pathname.match(/([a-z]+.html)/g);
exampleLinks(m ? m[0] : 'index.html');
})();