forked from marchaos/toggle-switch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
66 lines (58 loc) · 2.19 KB
/
demo.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
<html>
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
<script src="ToggleSwitch.js"></script>
<link rel="stylesheet" href="css/toggleswitch.css" />
<style>
html, body {
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
}
.ts-track {
margin-left: 30px;
}
</style>
<script>
var readyStateCheckInterval = setInterval(function() {
if (document.readyState === "complete") {
clearInterval(readyStateCheckInterval);
init();
}
}, 10);
function init() {
var oSmallToggle = new ToggleSwitch(document.getElementById('toggle'), "ON", "OFF");
var oSmallOrangeToggle = new ToggleSwitch(document.getElementById('toggle2'), "YES", "NO");
var oBlueToggle = new ToggleSwitch(document.getElementById('toggle3'), "YES", "NO");
var oOrangeToggle = new ToggleSwitch(document.getElementById('toggle4'), "ON", "OFF");
var oSmallToggleDisable = new ToggleSwitch(document.getElementById('toggleDisable'), "ON", "OFF");
var oBlueToggleDisable = new ToggleSwitch(document.getElementById('toggleDisable2'), "ON", "OFF");
oSmallToggle.addListener(function(bEnabled) {
oBlueToggle.toggle();
});
oSmallOrangeToggle.addListener(function(bEnabled) {
(bEnabled) ? oOrangeToggle.on() : oOrangeToggle.off();
});
oSmallToggleDisable.addListener(function(bEnabled) {
if(oBlueToggleDisable.isDisabled())
oBlueToggleDisable.enable();
else
oBlueToggleDisable.disable();
});
oBlueToggleDisable.addListenerTryChangeDisable(function() {
alert("Try change disabled");
});
}
</script>
</head>
<body>
<input class="blue small" checked="checked" id="toggle" type="checkbox" />
<input class="orange small" id="toggle2" type="checkbox" />
<input class="blue" id="toggle3" type="checkbox" />
<input class="orange" id="toggle4" type="checkbox" />
<input class="blue small" checked="checked" id="toggleDisable" type="checkbox" />
<input class="blue" id="toggleDisable2" type="checkbox" />
</body>
</html>