forked from aterrien/jQuery-Knob
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.html
59 lines (58 loc) · 1.67 KB
/
example.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
<!DOCTYPE html>
<html>
<head>
<script src="./js/jquery-1.12.2.js"></script>
<script src="./js/jquery.knob.js"></script>
</head>
<body>
<input type="text" value="0" class="dial">
<span id="initAngle"></span>
<span id="realVal"></span>
<button id="test1">Test reset</button>
<button id="test2">Test value</button>
<button id="test3">Show values</button>
<script>
$(function() {
var dialAngle = 0;
var dialVal = 0;
$(".dial").knob({
'min': 0,
'max': 360,
'firstClickSetStart': true,
'release' : function (v) {
console.log(v);
if(this.o.firstClickSetStart) {
$('#initAngle').text(v);
$('#realVal').text(0);
dialAngle = v;
dialVal = 0;
} else {
$('#initAngle').text((this.o.initialAngle || 0));
$('#realVal').text(v);
dialAngle = this.o.initialAngle || 0;
dialVal = v;
}
},
});
$('#test1').click(function() {
$('.dial').trigger(
'configure',
{
"fgColor":"#FF0000",
"skin":"tron",
"initialAngle": 45,
"firstClickSetStart": false,
}
);
});
$('#test2').click(function() {
$('.dial').val(90).trigger('change');
});
$('#test3').click(function() {
alert(dialAngle);
alert(dialVal);
});
});
</script>
</body>
</html>