-
Notifications
You must be signed in to change notification settings - Fork 28
/
demo.html
228 lines (174 loc) · 9.53 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
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
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>LC Switch - by LCweb</title>
<!-- PAGE BASE CSS -->
<style type="text/css"> a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,output,p,pre,q,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:'';content:none}table{border-collapse:collapse;border-spacing:0}
*{box-sizing:border-box;line-height:normal}body{background:#fcfcfc;font-family:sans-serif;color:#303030}.container:after{content:"";display:block;clear:both}.header{text-align:center;padding:40px 20px 20px;background:#343434;border-bottom:4px solid #7dc242;position:relative;z-index:2;overflow:hidden;color:#fefefe;}#logo{border:0;background:#343434;padding:0;position:relative;bottom:-5px;width:29px;margin-right:5px}svg{filter:blur(1px);opacity:.015;position:absolute;top:0;left:0;right:0;bottom:0;transform:rotate(3deg) scale(1.35);z-index:-1}.left-shade{fill:#afafaf}.right-shade{fill:#bfbfbf}.header h2{font-size:34px;margin-top:-12px;}.header h4{font-size:18px;font-weight:400;line-height:135%;margin:15px 0;color:#f0f0f0;}.header h4 a{color:#cfcfcf;}.content{max-width:1200px; margin:auto;}
</style>
<style>
#second_div{
width: 90%;
max-width: 700px;
min-width: 340px;
margin: 50px auto 0;
background: #f3f3f3;
border: 6px solid #eaeaea;
padding: 20px 40px 40px;
text-align: center;
border-radius: 2px;
}
#second_div p {
margin-bottom: 18px;
}
#third_div {
width: 90%;
max-width: 700px;
min-width: 340px;
margin: 30px auto;
}
#third_div small {
float: right;
padding-top: 5px;
}
small {
color: #929292;
cursor: pointer;
font-size: 90%;
}
#third_div ul {
padding: 15px 0;
max-height: 200px;
overflow: auto;
}
#third_div li {
color: #777;
font-size: 14px;
line-height: normal;
margin: 7px 0;
padding: 6px 2px;
margin: 0;
transition: all .2s ease;
}
#third_div li:hover {
background-color: #f3f3f3;
}
#third_div li em {
display: inline-block;
width: 200px;
color: #555;
font-style: normal;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h2>
<img id="logo" src=" data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAlCAMAAAD7q3BLAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAxQTFRFS1NFfsJCx8jKNDQ0SyWmjgAAAAR0Uk5T////AEAqqfQAAACySURBVHja7JTLFsQgCEOD/P8/jw9EgjiLWU88XQi3sSoUSgJaQwrRRNqQ4EWgbQEVcfKTuQgwEGxQGZANXnlnUCzAS0Hf+WXTB3lA1vDAPBxHEMWbWnM+bnFXse1g2ZnOBjshlhuPbPVZIIzRk7+JGYnAr4R8J/RPXGcaxXd77i71JxHi7+pVY0KMEVTudKXji69aj5WVidUvSgwRiH1bEMi9n4jc+26zCdT/ICdi9CPAAHRlCGHRLtsqAAAAAElFTkSuQmCC" />
LC Switch
</h2>
<h4>Superlight javascript plugin improving forms look and functionality, by <a href="https://lcweb.it" target="_blank">LCweb</a></h4>
<svg width="100%" height="100%">
<pattern id="pattern-cubes" x="0" patternUnits="userSpaceOnUse" viewBox="0 0 10 16" height="100" width="116" y="68">
<g id="cube">
<path class="left-shade" d="M0 0l5 3v5l-5 -3z" />
<path class="right-shade" d="M10 0l-5 3v5l5 -3" />
</g>
<use x="5" y="8" xlink:href="#cube" />
<use x="-5" y="8" xlink:href="#cube" />
</pattern>
<rect x="0" y="0" width="100%" height="100%" fill="url(#pattern-cubes)" />
</svg>
</div>
<div class="content">
<!-- //////////////////////////////////////////////// -->
<!-- REQUIRED HTML -->
<div id="second_div">
<form>
<div style="float: left; width: 50%;">
<p style="padding-bottom: 13px;"><em>Checkbox</em></p>
<p><input type="checkbox" name="check-1" value="1" class="lcs_check" autocomplete="off" /></p>
<p><input type="checkbox" name="check-2" value="2" class="lcs_check" disabled="disabled" autocomplete="off" /></p>
<p><input type="checkbox" name="check-3" value="3" class="lcs_check lcs_tt1" checked="checked" autocomplete="off" /></p>
<p><br/><small id="enable_ckb">(enable all)</small> <small id="disable_ckb">(disable all)</small></p>
</div>
<div style="float: right; width: 50%;">
<p style="padding-bottom: 13px;"><em>Radio<br/>(compact mode + custom color)</em></p>
<p><input type="radio" name="radio-1" value="1" class="lcs_check lcs_tt2" autocomplete="off" /></p>
<p><input type="radio" name="radio-1" value="2" class="lcs_check lcs_tt2" disabled="disabled" autocomplete="off" /></p>
<p><input type="radio" name="radio-1" value="3" class="lcs_check lcs_tt2" checked="checked" autocomplete="off" /></p>
<p><br/><small id="enable_radio">(enable all)</small> <small id="disable_radio">(disable all)</small></p>
</div>
</form>
<div style=" clear: both;"></div>
</div>
<div id="third_div">
<h3>
Events log:
<small>(clean)</small>
</h3>
<ul></ul>
</div>
<!-- //////////////////////////////////////////////// -->
</els
<!-- //////////////////////////////////////////////// -->
<!-- REQUIRED JAVASCRIPT -->
<script src="lc_switch.js" type="text/javascript"></script>
<script type="text/javascript">
const checkboxes = 'input[type=checkbox]',
radios = 'input[type=radio]';
// initialization
lc_switch(checkboxes);
lc_switch(radios, {
compact_mode : true,
on_color : 'teal',
});
// enable/disable
document.getElementById('enable_ckb').addEventListener('click', () => { lcs_enable(checkboxes); });
document.getElementById('disable_ckb').addEventListener('click', () => { lcs_disable(checkboxes); });
document.getElementById('enable_radio').addEventListener('click', () => { lcs_enable(radios); });
document.getElementById('disable_radio').addEventListener('click', () => { lcs_disable(radios); });
// events log
const log_wrap = document.querySelector('#third_div ul');
const toLeadingZero = (val) => {
return (val.toString().length < 2) ? '0'+val : val;
};
const getTime = () => {
const d = new Date;
return '('+ toLeadingZero(d.getHours()) +':'+ toLeadingZero(d.getMinutes()) +':'+ toLeadingZero(d.getSeconds()) +')';
};
document.querySelectorAll('input').forEach(function(el) {
const subj = el.getAttribute('type') +' #'+ el.value;
el.addEventListener('lcs-statuschange', (e) => {
let status = (el.checked) ? 'checked' : 'unchecked';
status += (el.disabled) ? ' disabled' : ' enabled';
log_wrap.innerHTML = '<li><em>'+ getTime() +' [lcs-statuschange]</em>'+ subj +' changed status: '+ status +'</li>' + log_wrap.innerHTML;
});
el.addEventListener('lcs-on', (e) => {
const status = (el.checked) ? 'checked' : 'unchecked';
log_wrap.innerHTML = '<li><em>'+ getTime() +' [lcs-on]</em>'+ subj +' changed status: '+ status +'</li>' + log_wrap.innerHTML;
});
el.addEventListener('lcs-off', (e) => {
const status = (el.checked) ? 'checked' : 'unchecked';
log_wrap.innerHTML = '<li><em>'+ getTime() +' [lcs-off]</em>'+ subj +' changed status: '+ status +'</li>' + log_wrap.innerHTML;
});
el.addEventListener('lcs-enabled', (e) => {
const status = (el.disabled) ? 'disabled' : 'enabled';
log_wrap.innerHTML = '<li><em>'+ getTime() +' [lcs-enabled]</em>'+ subj +' changed status: '+ status +'</li>' + log_wrap.innerHTML;
});
el.addEventListener('lcs-disabled', (e) => {
const status = (el.disabled) ? 'disabled' : 'enabled';
log_wrap.innerHTML = '<li><em>'+ getTime() +' [lcs-disabled]</em>'+ subj +' changed status: '+ status +'</li>' + log_wrap.innerHTML;
});
});
// clear events log
document.querySelector('#third_div small').addEventListener('click', () => {
log_wrap.innerHTML = '';
});
</script>
<!-- //////////////////////////////////////////////// -->
</body>
</html>