-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
391 lines (365 loc) · 15.7 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
380
381
382
383
384
385
386
387
388
389
390
391
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Simple button radios is a simple plugin for transform radio inputs into html buttons for css customize.">
<link rel="stylesheet" href="demo/css/bootstrap.min.css">
<link rel="stylesheet" href="dist/css/simple-button-radios.css">
<link rel="stylesheet" href="demo/css/demo.css">
<link rel="apple-touch-icon" sizes="57x57" href="demo/img/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="demo/img/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="demo/img/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="demo/img/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="demo/img/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="demo/img/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="demo/img/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="demo/img/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="demo/img/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="demo/img/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="demo/img/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="demo/img/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="demo/img/favicon-16x16.png">
<meta name="msapplication-TileColor" content="#343a40">
<meta name="msapplication-TileImage" content="demo/img/ms-icon-144x144.png">
<meta name="theme-color" content="#343a40">
<title>Simple button radios</title>
</head>
<body>
<nav class="navbar navbar-dark fixed-top bg-dark flex-md-nowrap p-0 shadow">
<a class="navbar-brand col-sm-3 col-md-2 mr-0" href="#">Simple button radios <span class="badge badge-pill badge-primary">v1.0.4</span></a>
<ul class="navbar-nav px-3">
<li class="nav-item text-nowrap">
<a class="nav-link" href="https://github.com/joelthorner/simple-button-radios" target="_blank">Github <svg class="icon" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"></path></svg></a>
</li>
</ul>
</nav>
<div class="container-fluid">
<div class="row">
<nav class="col-md-2 d-none d-md-block bg-light sidebar">
<div class="sidebar-sticky">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="#getting-started">
Getting started <span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#options">
Options
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#callbacks">
Callbacks
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#methods">
Methods
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#demo">
Demo
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#changelog">
Changelog
</a>
</li>
</ul>
</div>
</nav>
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-4">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h1">Simple button radios</h1>
<div class="btn-toolbar mb-2 mb-md-0">
<div class="btn-group mr-2">
<a class="github-button" href="https://github.com/joelthorner/simple-button-radios/issues" data-icon="octicon-issue-opened" data-size="large" data-show-count="true" aria-label="Issue joelthorner/simple-button-radios on GitHub">Issue</a>
<a class="github-button" href="https://github.com/joelthorner/simple-button-radios" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star joelthorner/simple-button-radios on GitHub">Star</a>
<a class="github-button" href="https://github.com/joelthorner/simple-button-radios/archive/master.zip" data-icon="octicon-cloud-download" data-size="large" aria-label="Download joelthorner/simple-button-radios on GitHub">Download</a>
</div>
</div>
</div>
<p>Simple button radios is a simple plugin for transform radio inputs into html buttons for css customize. High performance, keyboard support and preserve original input click/change events.</p>
<br>
<h2 id="getting-started">Getting started</h2>
<br>
<h3 class="h5">1. Include Simple button radios files to website/app</h3>
<p>After that we need to include CSS and JS files to our website/app. In your html file:</p>
<div class="editor-wrp">
<div class="editor html"><!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="path/to/simple-button-radios.css">
</head>
<body>
<script src="path/to/jquery/3.x.x.min.js"></script>
<script src="path/to/simple-button-radios.js"></script>
</body>
</html></div>
</div>
<br>
<h3 class="h5">2. Add html inputs</h3>
<p>This plugin contemplates several label-input formats:</p>
<div class="editor-wrp">
<div class="editor html"><div class="radio">
<input type="radio" name="example" id="example1" value="1" checked>
<label for="example1">Use address 1</label>
</div>
<div class="radio">
<input type="radio" name="example" id="example2" value="2">
<label for="example2">Use address 2</label>
</div>
<!-- or -->
<div class="radio">
<label for="example1">Use address 1</label>
<input type="radio" name="example" id="example1" value="1" checked>
</div>
<div class="radio">
<label for="example2">Use address 2</label>
<input type="radio" name="example" id="example2" value="2">
</div>
</div>
</div>
<br>
<h3 class="h5">3. Initialize plugin</h3>
<p>After load jquery and simple-button-radios js files</p>
<div class="editor-wrp">
<div class="editor js">$(document).ready(function () {
// initialize plugin into document ready
$('input[type="radio"]').simpleButtonRadios();
});</div>
</div>
<br>
<br>
<h2 id="options">Options</h2>
<br>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>buttonClass</code></td>
<td><code>string</code></td>
<td><code>'sbr-default'</code></td>
<td>Class attribute value for new html button tag</td>
</tr>
<tr>
<td><code>checkedIcon</code></td>
<td><code>string</code></td>
<td><code style="width: 290px;display: block;">'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="-725.53 115.775 1451.338 1451.338"><path d="M.141 376.731c-256.717 0-464.713 207.995-464.713 464.713 0 256.72 207.997 464.715 464.713 464.715 256.718 0 464.712-207.995 464.712-464.715 0-256.718-207.994-464.713-464.712-464.713z"/></svg>'</code></td>
<td>button inner html when input is checked</td>
</tr>
<tr>
<td><code>nonCheckedIcon</code></td>
<td><code>string</code></td>
<td><code>''</code></td>
<td>button inner html when input is not checked</td>
</tr>
<tr>
<td><code>wrapContainer</code></td>
<td><code>string</code></td>
<td><code>'none'</code></td>
<td>Values: 'none' or 'input' or 'all'. Wrap with a div label and input, only input or nothing.</td>
</tr>
<tr>
<td><code>btnAttributes</code></td>
<td><code>object</code></td>
<td><code>{ type : 'button' }</code></td>
<td>
Add attribute name - value into new html button. Example:<br>
<code>btnAttributes: {<br>
data-title : 'string value'<br>
}</code>
</td>
</tr>
</body>
</table>
</div>
<br>
<h2 id="callbacks">Callbacks</h2>
<br>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<body>
<tr>
<td><code>onInit(simpleButtonRadios)</code></td>
<td><code>function</code></td>
<td><code>null</code></td>
<td>Callback function, will be executed right after plugin initialization</td>
</tr>
<tr>
<td><code>onChange(simpleButtonRadios)</code></td>
<td><code>function</code></td>
<td><code>null</code></td>
<td>Function, will be executed right before radio input change</td>
</tr>
<tr>
<td><code>changeCallback(simpleButtonRadios)</code></td>
<td><code>function</code></td>
<td><code>null</code></td>
<td>Callback function, will be executed right after radio input change</td>
</tr>
<tr>
<td><code>onDestroy(simpleButtonRadios)</code></td>
<td><code>function</code></td>
<td><code>null</code></td>
<td>Callback function, will be executed when you destroy Swiper</td>
</tr>
</tbody>
</table>
</div>
<br>
<h2 id="methods">Methods</h2>
<br>
<p>After we initialize input/s we have its initialized instance in variable (like myInput variable in example below) with helpful methods:</p>
<div class="editor-wrp">
<div class="editor js">var myInput = $('#check-1').simpleButtonRadios({
checkedIcon : '<span class="custom-icon"></span>'
});
myInput.simpleButtonRadios('destroy');</div>
</div>
<br>
<div class="alert alert-warning" role="alert">
<h3 class="alert-heading">Check / unckeck</h4>
<p><b>Mode 1:</b> <a class="alert-link" href="http://api.jquery.com/prop/" target="_blank">jQuery prop method</a> into original input and update method. <br><code>$('#check-one').prop('checked', true).simpleButtonRadios('update');</code></p>
<p><b>Mode 2:</b> <a class="alert-link" href="http://api.jquery.com/prop/" target="_blank">jQuery prop method</a> into original input with change event:<br><code>$('#check-one').prop('checked', true).trigger('change');</code></p>
<p><b>Mode 3:</b> Use click event into original input:<br><code>$('#check-one').click();</code></p>
</div>
<br>
<div class="table-responsive">
<table class="table table-bordered" id="t_methods">
<thead>
<tr>
<th>Method</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>myInput.simpleButtonRadios(<span>'destroy'</span>);</code></td>
<td>Destroy simpleButtonRadios instance and detach all events listeners</td>
</tr>
<tr>
<td><code>myInput.simpleButtonRadios(<span>'addListener'</span>, <span>node</span>);</code></td>
<td>
Add change radio input event to a node. Example:<br>
<code>myInput.simpleButtonRadios('addListener', $('#div-1'));</code>
</td>
</tr>
<tr>
<td><code>myInput.simpleButtonRadios(<span>'disable'</span>, <span>boolean</span>);</code></td>
<td>
Enable | disable input. Example:<br>
<code>myInput.simpleButtonRadios('disable', true);</code>
</td>
</tr>
<tr>
<td><code>myInput.simpleButtonRadios(<span>'update'</span>);</code></td>
<td>Refresh all radios grouped by name attr</td>
</tr>
</tbody>
</table>
</div>
<br>
<h2 id="demo">Demo</h2>
<p>Customized</p>
<iframe class="demo" src="examples/01.html" frameborder="0"></iframe>
<br>
<br>
<p>Defaults & js check tests</p>
<iframe class="demo" src="examples/02.html" frameborder="0" style="min-height: 290px;"></iframe>
<br>
<br>
<p>Add dynamic radios</p>
<iframe class="demo" src="examples/03.html" frameborder="0"></iframe>
<br>
<br>
<h2 id="changelog">Changelog</h2>
<h3>1.0.4</h3>
<ul>
<li>Fix on destroy and disable public methods undefined data</li>
<li>Fix apply method on elements without data</li>
<li>Fix destroy method not remove focus events</li>
</ul>
<h3>1.0.3</h3>
<ul>
<li>Add update method</li>
<li>Update demos and add demo with dynamic inputs</li>
</ul>
<h3>1.0.2</h3>
<ul>
<li>Fix bug inputId is undefined</li>
</ul>
<h3>1.0.1</h3>
<ul>
<li>Now is possible unckeck all radios</li>
<li>Removed strictLabel option, use native browser function</li>
<li>Update documentation info and add default plugin demos</li>
</ul>
<br>
<br>
<br>
</main>
</div>
</div>
<script src="demo/js/jquery-3.3.1.min.js"></script>
<script src="demo/js/popper.min.js"></script>
<script src="demo/js/bootstrap.min.js"></script>
<script src="dist/js/simple-button-radios.js"></script>
<script async defer src="https://buttons.github.io/buttons.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.3/ace.js" integrity="sha256-NLPE2EQpOtxTAUB/jxjM97jsGmVQopiX8ceHySHhXs8=" crossorigin="anonymous"></script>
<script>
$(document).ready(function() {
$('[type="radio"]').simpleButtonRadios();
// demo
$('#year').text(new Date().getFullYear());
var $editors = $('.editor');
for (var i = 0; i < $editors.length; i++) {
var editor = ace.edit($editors[i]);
editor.setTheme("ace/theme/xcode");
if($($editors[i]).hasClass('html')) editor.session.setMode("ace/mode/html");
else editor.session.setMode("ace/mode/javascript");
editor.setOptions({
showPrintMargin: false,
useWorker:false,
maxLines: Infinity,
showGutter : false,
highlightActiveLine : false,
cursorStyle : "slim",
fontFamily : 'SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace'
});
}
$('.sidebar .nav-link').click(function(event) {
event.preventDefault();
$('.sidebar .nav-link').removeClass('active');
$(this).addClass('active');
var top = $( $(this).attr('href') ).offset().top;
$('html, body').animate({ scrollTop: top - 48 - 15 }, 350)
});
});
</script>
</body>
</html>