-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.html
221 lines (182 loc) · 6.16 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
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Jquery Switcher - Janic Beauchemin</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="./dist/switcher.css"/>
<style>
html {
font-family: 'Oswald', sans-serif;
text-align: center;
text-transform: uppercase;
}
h1 {
font-size: 35px;
font-weight: normal;
}
h2, h4 {
margin-bottom: 0;
}
h3 {
margin: 0.5em 0;
}
label {
font-size: 14px;
margin-bottom: 5px;
display: inline-block;
*display: inline;
*zoom: 1;
}
.style {
border-bottom: 3px solid #519b20;
text-align: left;
margin: 0 auto;
max-width: 1024px;
padding-bottom: 30px;
}
.checkbox,
.radio {
vertical-align: top;
width: 45%;
display: inline-block;
*display: inline;
*zoom: 1;
}
button {
line-height: 1.6em;
margin: 3px;
width: 110px;
}
</style>
</head>
<body>
<h1>Jquery Switcher</h1>
<div class="style style1">
<h2>Style #1 (default):</h2>
<div class="checkbox">
<h3>Checkbox</h3>
<input type="checkbox" name="switchCheck1" value="switchCheck1" />
<h4>Controls:</h4>
<button class="btnCheck">check</button>
<button class="btnUncheck">uncheck</button>
<br/>
<button class="btnEnabled">enable</button>
<button class="btnDisabled">disable</button>
<br/>
<button class="btnFrench">french</button>
<button class="btnEnglish">english</button>
<br/>
<button class="btnGetLanguage">get lang</button>
</div>
<div class="radio">
<h3>Radio</h3>
<input type="radio" name="switchRadio1" value="one">
<input type="radio" name="switchRadio1" value="two">
<input type="radio" name="switchRadio1" value="three">
<h4>Controls:</h4>
<button class="btnCheck1">check1</button>
<button class="btnCheck2">check2</button>
<button class="btnCheck3">check3</button>
<br/>
<button class="btnEnabled">enable</button>
<button class="btnDisabled">disable</button>
<br/>
<button class="btnFrench">french</button>
<button class="btnEnglish">english</button>
<br/>
<button class="btnGetLanguage">get lang</button>
</div>
</div>
<div class="style style2">
<h2>Style #2 (short):</h2>
<div class="checkbox">
<h3>Checkbox</h3>
<label>
<input type="checkbox" name="switchCheck2" value="switchCheck2" /> checkbox example
</label>
</div>
<div class="radio">
<h3>Radio</h3>
<label>
<input type="radio" name="switchRadio2" value="one"> radio example 1
</label>
<br/>
<label>
<input type="radio" name="switchRadio2" value="two"> radio example 2
</label>
<br/>
<label>
<input type="radio" name="switchRadio2" value="three"> radio example 3
</label>
</div>
</div>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="./dist/switcher.js"></script>
<script type="text/javascript">
$(function () {
var switcher1 = $('.style1 input').switcher();
var switcher2 = $('.style2 input').switcher({
style: 'short'
});
var checkbox = $('[name="switchCheck1"]');
$('.checkbox .btnCheck').on('click', function () {
checkbox.switcher('setValue', true);
});
$('.checkbox .btnUncheck').on('click', function () {
checkbox.switcher('setValue', false);
});
$('.checkbox .btnEnabled').on('click', function () {
checkbox.switcher('setDisabled', false);
});
$('.checkbox .btnDisabled').on('click', function () {
checkbox.switcher('setDisabled', true);
});
$('.checkbox .btnFrench').on('click', function () {
checkbox.switcher('setLanguage', 'fr');
});
$('.checkbox .btnEnglish').on('click', function () {
checkbox.switcher('setLanguage', 'en');
});
$('.checkbox .btnGetLanguage').on('click', function () {
checkbox.switcher('getLanguage', function (value) {
alert('language value: ' + value);
});
});
var radio = $('[name="switchRadio1"]');
$('.radio .btnCheck1').on('click', function () {
radio.eq(0).switcher('setValue', true);
});
$('.radio .btnCheck2').on('click', function () {
radio.eq(1).switcher('setValue', true);
});
$('.radio .btnCheck3').on('click', function () {
radio.eq(2).switcher('setValue', true);
});
$('.radio .btnEnabled').on('click', function () {
radio.switcher('setDisabled', false);
});
$('.radio .btnDisabled').on('click', function () {
radio.switcher('setDisabled', true);
});
$('.radio .btnFrench').on('click', function () {
radio.switcher('setLanguage', 'fr');
});
$('.radio .btnEnglish').on('click', function () {
radio.switcher('setLanguage', 'en');
});
$('.radio .btnGetLanguage').on('click', function () {
radio.eq(0).switcher('getLanguage', function (value) {
alert('language value: ' + value);
});
});
});
</script>
</body>
</html>