-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfmfriend-view.js
97 lines (94 loc) · 3 KB
/
fmfriend-view.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
$(function() {
var fmf = new FmFriend();
var fmf_slider = Vue.component('fmf-slider', {
props: ["fmf", "param"],
data: function() {
return {
value: this.param.get()
};
},
template: [
'<div class="slider-container">',
' <h2>{{ param.name }}</h2>',
' <div class="slider">',
' <input type="range" :min="param.min" :max="param.max" v-model.number="param_prop" v-on:input="fmf.updated"></input>',
' <div class="display">',
' <label>{{ param_prop }}</label>',
' </div>',
' </div>',
'</div>'
].join("\n"),
computed: {
param_prop: {
get: function() {
return this.value;
},
set: function(value) {
this.param.set(value);
this.value = this.param.get();
}
}
}
});
var fmf_radios = Vue.component('fmf-radios', {
props: ["fmf", "param", "operator", "group", "pretty"],
data: function() {
return {
value: this.param.get()
};
},
template: [
'<div class="radios-container">',
' <h2>{{ param.name }}</h2>',
' <div class="radios">',
' <div v-for="value in values()" class="radio-container" >',
' <input :name="name()" :id="id(value)" type="radio" v-model.number="param_prop" :value="value" v-on:change="fmf.updated"><label :for="id(value)">{{ pretty_value(value) }}</label>',
' </div>',
' </div>',
'</div>'
].join("\n"),
computed: {
param_prop: {
get: function() {
return this.value;
},
set: function(value) {
this.param.set(value);
this.value = this.param.get();
}
}
},
methods: {
values: function() {
return _.range(this.param.min, this.param.max + 1);
},
name: function() {
return this.group + "-" + this.operator;
},
id: function(value) {
return this.name() + "-" + value;
},
pretty_value: function(value) {
return this.pretty ? this.pretty(value) : value;
}
}
});
var vue = new Vue({
el: "#fmfriend",
data: {
fmf: fmf
},
computed: {
patch_name: {
get: fmf.get_name,
set: fmf.set_name
},
param: function(index) {
return {
get: fmf.param_defs[index].get,
set: fmf.param_defs[index].set
};
}
}
});
});