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
|
<template>
<div id="accessibility">
<div id="themes" class="section">
<h2>{{t('accessibility', 'Themes')}}</h2>
<div class="themes-list preview-list">
<preview v-for="preview in themes" :preview="preview"
:key="preview.id" :selected="selected.theme"
v-on:select="selectTheme"></preview>
</div>
</div>
<div id="fonts" class="section">
<h2>{{t('accessibility', 'Fonts')}}</h2>
<div class="fonts-list preview-list">
<preview v-for="preview in fonts" :preview="preview"
:key="preview.id" :selected="selected.font"
v-on:select="selectFont"></preview>
</div>
</div>
</div>
</template>
<script>
import preview from './components/itemPreview';
export default {
name: 'app',
components: { preview },
beforeMount() {
// importing server data into the app
const serverDataElmt = document.getElementById('serverData');
if (serverDataElmt !== null) {
this.serverData = JSON.parse(
document.getElementById('serverData').dataset.server
);
}
},
data() {
return {
serverData: []
};
},
computed: {
themes() {
return this.serverData.themes;
},
fonts() {
return this.serverData.fonts;
},
selected() {
return {
theme: this.serverData.theme,
font: this.serverData.font
};
}
},
methods: {
selectTheme(id) {
this.selectItem('theme', id);
},
selectFont(id) {
this.selectItem('font', id);
},
/**
* Commit a change
*
* @param {string} type type of the change (font or theme)
* @param {string} id the data of the change
*/
selectItem(type, id) {
this.serverData[type] = id;
console.log(type, id);
}
}
};
</script>
|