-
Notifications
You must be signed in to change notification settings - Fork 44
/
index.html
379 lines (337 loc) · 13.1 KB
/
index.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/customize-presets.css">
<link rel="stylesheet" href="lib/presets/p1.css">
<link rel="stylesheet" href="lib/presets/p2.css">
<link rel="stylesheet" href="lib/presets/p3.css">
<link rel="stylesheet" href="lib/presets/p4.css">
<link rel="stylesheet" href="lib/presets/p5.css">
<script type="text/javascript" src="dist/knob.js"></script>
<script type="text/javascript" src="lib/presets/p1.js"></script>
<script type="text/javascript" src="lib/presets/p2.js"></script>
<script type="text/javascript" src="lib/presets/p3.js"></script>
<script type="text/javascript" src="lib/presets/p4.js"></script>
<script type="text/javascript" src="lib/presets/p5.js"></script>
<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Lekton:400italic' rel='stylesheet' type='text/css'>
<link href="http://fonts.googleapis.com/css?family=Titillium+Web:400,600,400italic,700" rel="stylesheet"
type="text/css">
<style>
.p1 circle {
filter: url(#dropshadow);
}
.p3 path {
filter: url(#inner-shadow)
}
.p6 text {
font-size: 12px !important;
fill: #57C7B6;
font-weight: 300;
}
</style>
</head>
<body>
<a href="https://github.com/eskimoblood/jim-knopf"><img style="position: absolute; top: 0; right: 0; border: 0;"
src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png"
alt="Fork me on GitHub"></a>
<h2>Presets</h2>
<p></p>
<ul class="row">
<li>
<input class="preset1" type="range" min="0" max="10" data-width="100" data-height="100" data-angleOffset="220"
data-angleRange="280">
</li>
<li>
<input class="preset2" type="range" min="0" max="10" data-width="100" data-height="100" data-angleOffset="220"
data-angleRange="280">
</li>
<li>
<input class="preset3" type="range" min="0" max="10" data-width="100" data-height="100" data-angleOffset="220"
data-angleRange="280">
</li>
<li>
<input class="preset4" type="range" min="0" max="10" data-width="100" data-height="100" data-angleOffset="220"
data-angleRange="280">
</li>
<li>
<input class="preset5" type="range" min="0" max="10" data-width="100" data-height="100" data-angleOffset="220"
data-angleRange="280">
</li>
</ul>
<h2>Knobs as switch</h2>
<p>Knobs can be used as switches too if they are supplied with a <code>data-labels</code>attribute</p>
<ul class="row">
<li class="column">
<input class="preset1" type="range" data-width="150" data-height="150" data-angleOffset="270" data-angleRange="180" data-labels="test1,test2,test3,test4,text5" />
<code>data-angleOffset="270</code><br>
<code>data-angleRange="180"</code><br>
<code>data-labels="test1,test2,test3,test4,text5"</code><br>
<code>class="preset1"</code><br>
</li>
<li class="column">
<input id='p6' type="range" data-width="150" data-height="150" data-angleOffset="270" data-angleRange="180" data-labels="test1,test2,test3,test4,text5,text6" />
<code>data-angleOffset="270</code><br>
<code>data-angleRange="180"</code><br>
<code>data-labels="test1,test2,test3,test4,text5"</code><br>
<code>class="preset1"</code><br>
</li>
</ul>
<script type="text/javascript">
Ui.P6 = function() {};
Ui.P6.prototype = Object.create(Ui.prototype);
Ui.P6.prototype.createElement = function() {
Ui.prototype.createElement.apply(this, arguments);
this.addComponent(new Ui.Pointer({
type: 'Arc',
size: 30,
outerRadius: this.width / 2.6,
innerRadius: this.width / 2.6 - this.width / 6,
angleoffset: this.options.angleoffset
}));
// this.addComponent(new Ui.Text());
this.addComponent(new Ui.Scale(this.merge(this.options, {
drawScale: false,
drawDial: true,
radius: this.width/2.5
})));
var circle = new Ui.El.Circle(this.width / 2.1, this.width / 2, this.height / 2);
this.el.node.appendChild(circle.node);
this.el.node.setAttribute("class", "p5 p6");
};
new Knob(document.getElementById('p6'), new Ui.P6());
</script>
<h2>Scale it</h2>
<p>As all knobs are made with SVG they scale. Use the <code>data-size</code> attribute to set the size of a knob</p>
<ul class="row">
<li class="column">
<input class="preset2" type="range" min="0" max="10" data-width="300" data-height="300" data-angleOffset="220"
data-angleRange="280">
</li>
<li class="column">
<input class="preset2" type="range" min="0" max="10" data-width="200" data-height="200" data-angleOffset="220"
data-angleRange="280">
<input class="preset2" type="range" min="0" max="10" data-width="100" data-height="100" data-angleOffset="220"
data-angleRange="280">
</li>
<li class="column">
<input class="preset2" type="range" min="0" max="10" data-width="90" data-height="90" data-angleOffset="220"
data-angleRange="280">
<input class="preset2" type="range" min="0" max="10" data-width="60" data-height="60" data-angleOffset="220"
data-angleRange="280">
<input class="preset2" type="range" min="0" max="10" data-width="30" data-height="30" data-angleOffset="220"
data-angleRange="280">
</li>
</ul>
<h2>Customize</h2>
<p>
Customize the scale using <code>min</code>, <code>max</code>, <code>data-angleOffset</code> and
<code>data-angleRange</code>.
Where <code>min</code> & <code>max</code> defines the minimal and maximal value of the knob.
<code>data-angleOffset</code> sets the angle (in degree) where the scale starts, default is 0.
<code>data-angleRange</code> sets the range of the scale between 0 and 360 degree.
<code>step</code> define the step in which the value increase.
</p>
<ul class="row">
<li class="column">
<input class="preset1" type="range" min="0" max="10" data-width="150" data-height="150"/>
<code>min="0"</code>
<code>max="10"</code>
</li>
<li class="column">
<input class="preset1" type="range" min="0" max="10" data-width="150" data-height="150" data-angleOffset="270"
data-angleRange="180" step="2"/>
<code>min="0"</code>
<code>max="10"</code>
<code>data-angleOffset="270</code>
<code>data-angleRange="180"</code>
<code>step="2"</code>
</li>
<li class="column">
<input class="preset1" type="range" min="-12" max="12" data-width="150" data-height="150" data-angleOffset="220"
data-angleRange="280" step="3"/>
<code>min="-12"</code>
<code> max="12"</code>
<code>data-angleOffset="220"</code>
<code>data-angleRange="280"</code>
<code>step="3"</code>
</li>
</ul>
<p>
As the knobs are build with SVG all parts can by styled with CSS.
</p>
<ul class="row customize">
<li>
<input class="preset1" type="range" min="0" max="10" data-width="100" data-height="100" data-angleOffset="220"
data-angleRange="280">
</li>
<li>
<input class="preset2" type="range" min="0" max="10" data-width="100" data-height="100" data-angleOffset="220"
data-angleRange="280">
</li>
<li>
<input class="preset3" type="range" min="0" max="10" data-width="100" data-height="100" data-angleOffset="220"
data-angleRange="280">
</li>
<li>
<input class="preset4" type="range" min="0" max="10" data-width="100" data-height="100" data-angleOffset="220"
data-angleRange="280">
</li>
</ul>
<h2>Build your own</h2>
<p>All knobs can be build of the following components</p>
<ul class="row">
<li class="column">
<h3>Pointer</h3>
<input class="pointerExample" type="range" min="0" max="10" data-width="100" data-height="100"
data-angleOffset="220"
data-angleRange="280">
</li>
<li class="column">
<h3>Arc</h3>
<input class="arcExample" type="range" min="0" max="10" data-width="100" data-height="100"
data-angleOffset="220"
data-angleRange="280">
</li>
<li class="column">
<h3>Scale</h3>
<input class="scaleExample" type="range" min="0" max="10" data-width="100" data-height="100"
data-angleOffset="220"
data-angleRange="280">
</li>
<li class="column">
<h3>Dial</h3>
<input class="dialExample" type="range" min="0" max="10" data-width="100" data-height="100"
data-angleOffset="220"
data-angleRange="280">
</li>
</ul>
<script type="text/javascript">
/**
* Just a lazy way to convert all inputs into knobs.
* Normally you would write `new Knob(document.getElementById('someIdHere'), new Ui.P1());` to create a knob.
*/
for (var i = 1; i < 6; i++) {
Array.prototype.slice.call(document.getElementsByClassName('preset' + i)).forEach(function(el) {
new Knob(el, new Ui['P' + i]());
el.addEventListener('change', function () {
console.log(el.value)
})
})
}
/**
* Create a simple slider with just a scale
*/
var ScaleExample = function() {};
ScaleExample.prototype = Object.create(Ui.prototype);
ScaleExample.prototype.createElement = function() {
Ui.prototype.createElement.apply(this, arguments);
this.addComponent(new Ui.Scale({
drawScale: true,
drawDial: false,
steps: 30,
tickWidth: 10,
tickHeight: 10,
type: 'Triangle'
}));
this.el.node.setAttribute("class", "scaleExample");
}
new Knob(document.getElementsByClassName('scaleExample')[0], new ScaleExample());
/**
* Create a simple slider with just a dial
*/
var DialExample = function() {};
DialExample.prototype = Object.create(Ui.prototype);
DialExample.prototype.createElement = function() {
Ui.prototype.createElement.apply(this, arguments);
this.addComponent(new Ui.Scale({
drawScale: false,
drawDial: true,
steps: 10
}));
this.el.node.setAttribute("class", "dialExample");
};
new Knob(document.getElementsByClassName('dialExample')[0], new DialExample());
/**
* Create a simple slider with just a pointer
*/
var PointerExample = function() {};
PointerExample.prototype = Object.create(Ui.prototype);
PointerExample.prototype.createElement = function() {
Ui.prototype.createElement.apply(this, arguments);
this.addComponent(new Ui.Pointer({
type: 'Circle',
pointerWidth: 3,
pointerHeight: this.width / 5,
offset: this.width / 2 - this.width / 3.3 - this.width / 10
}));
this.el.node.setAttribute("class", "pointerExample");
};
new Knob(document.getElementsByClassName('pointerExample')[0], new PointerExample());
/**
* Create a simple slider with just an acr
*/
var Arcxample = function() {};
Arcxample.prototype = Object.create(Ui.prototype);
Arcxample.prototype.createElement = function() {
Ui.prototype.createElement.apply(this, arguments);
this.addComponent(new Ui.Arc({
arcWidth: this.width / 10
}));
this.el.node.setAttribute("class", "arcExample");
};
new Knob(document.getElementsByClassName('arcExample')[0], new Arcxample());
</script>
<svg>
<filter id="dropshadow" height="150%" width="150%">
<feGaussianBlur in="SourceAlpha" stdDeviation="2"/>
<feOffset dx="0" dy="3" result="offsetblur"/>
<feMerge>
<feMergeNode/>
<feMergeNode in="SourceGraphic"/>
</feMerge>
</filter>
<filter id='inner-shadow'>
<!-- Shadow Offset -->
<feOffset
dx='0'
dy='5'
/>
<!-- Shadow Blur -->
<feGaussianBlur
stdDeviation='5'
result='offset-blur'
/>
<!-- Invert the drop shadow
to create an inner shadow -->
<feComposite
operator='out'
in='SourceGraphic'
in2='offset-blur'
result='inverse'
/>
<!-- Color & Opacity -->
<feFlood
flood-color='black'
flood-opacity='0.75'
result='color'
/>
<!-- Clip color inside shadow -->
<feComposite
operator='in'
in='color'
in2='inverse'
result='shadow'
/>
<!-- Put shadow over original object -->
<feComposite
operator='over'
in='shadow'
in2='SourceGraphic'
/>
</filter>
</svg>
</body>
</html>