Skip to content

Commit 035d3d5

Browse files
committed
updated for v1.0.0
1 parent 368063c commit 035d3d5

File tree

5 files changed

+1293
-115
lines changed

5 files changed

+1293
-115
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## Unreleased
88

9-
## [1.0.0](https://github.com/gitbrent/bootstrap-switch-button/tree/v1.0.0) 2019-01-19
9+
## [1.0.0](https://github.com/gitbrent/bootstrap-switch-button/tree/v1.0.0) 2019-03-05
1010
### Added
11-
- Initial release (cloned `bootstrap4-toggle`)
11+
- Initial release
1212
### Changed
1313

1414
[Unreleased]: https://github.com/gitbrent/bootstrap-switch-button/compare/v1.0.0...HEAD

README.md

Lines changed: 42 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,16 @@
22

33
# Bootstrap Switch Button
44

5-
**Bootstrap Switch Button** is a bootstrap plugin/widget that converts checkboxes into toggles.
6-
7-
Visit https://gitbrent.github.io/bootstrap-switch-button/ for interactive demos.
5+
**Bootstrap Switch Button** is a bootstrap plugin/widget that converts checkboxes into switch buttons.
86

97
**************************************************************************************************
108

11-
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
12-
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
13-
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
14-
15-
- [Demos](#demos)
16-
- [Installation](#installation)
17-
- [CDN](#cdn)
18-
- [Download](#download)
19-
- [NPM](#npm)
20-
- [Yarn](#yarn)
21-
- [Usage](#usage)
22-
- [Initialize With HTML](#initialize-with-html)
23-
- [Initialize With Code](#initialize-with-code)
24-
- [API](#api)
25-
- [Options](#options)
26-
- [Methods](#methods)
27-
- [Events](#events)
28-
- [Event Propagation](#event-propagation)
29-
- [API vs Input](#api-vs-input)
30-
31-
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
9+
# Demos
10+
Visit https://gitbrent.github.io/bootstrap-switch-button/ for interactive demos/documentation.
3211

33-
**************************************************************************************************
12+
![Demo GIF](https://github.com/gitbrent/bootstrap-switch-button/blob/master/img/bootstrap-switch-button-demo.gif?raw=true)
3413

35-
# Demos
36-
Visit https://gitbrent.github.io/bootstrap-switch-button/ for interactive checkbox toggle demos.
14+
**************************************************************************************************
3715

3816
# Installation
3917

@@ -59,21 +37,21 @@ yarn install bootstrap-switch-button
5937
# Usage
6038

6139
## Initialize With HTML
62-
Simply add `data-toggle="toggle"` to automatically convert a plain checkbox into a bootstrap 4 toggle.
40+
Simply add `data-toggle="switchButton"` to automatically convert a plain checkbox into a bootstrap 4 switch button.
6341

6442
```html
65-
<input id="chkToggle" type="checkbox" data-toggle="toggle">
43+
<input id="chkSwitch" type="checkbox" data-toggle="switchButton">
6644
```
6745

6846
## Initialize With Code
69-
Toggles can also be initialized via JavaScript code.
47+
Switch buttons can also be initialized via JavaScript code.
7048

71-
EX: Initialize id `chkToggle` with a single line of JavaScript.
49+
EX: Initialize id `chkSwitch` with a single line of JavaScript.
7250
```html
73-
<input id="chkToggle" type="checkbox" checked>
51+
<input id="chkSwitch" type="checkbox" checked>
7452
<script>
7553
$(function(){
76-
$('#chkToggle').bootstrapToggle();
54+
$('#chkSwitch').switchButton();
7755
});
7856
</script>
7957
```
@@ -85,11 +63,11 @@ EX: Initialize id `chkToggle` with a single line of JavaScript.
8563
* For data attributes, append the option name to `data-` (ex: `data-on="Enabled"`)
8664

8765
```html
88-
<input type="checkbox" data-toggle="toggle" data-on="Enabled" data-off="Disabled">
89-
<input type="checkbox" id="toggle-two">
66+
<input type="checkbox" data-toggle="switchButton" data-on="Enabled" data-off="Disabled">
67+
<input type="checkbox" id="switch-two">
9068
<script>
9169
$(function() {
92-
$('#toggle-two').bootstrapToggle({
70+
$('#switch-two').switchButton({
9371
on: 'Enabled',
9472
off: 'Disabled'
9573
});
@@ -99,46 +77,46 @@ EX: Initialize id `chkToggle` with a single line of JavaScript.
9977

10078
Name |Type |Default |Description |
10179
----------|-----------|----------|----------------------------|
102-
`on` |string/html|"On" |Text of the on toggle
103-
`off` |string/html|"Off" |Text of the off toggle
104-
`size` |string |"normal" |Size of the toggle. Possible values are: `large`, `normal`, `small`, `mini`.
105-
`onstyle` |string |"primary" |Style of the on toggle. Possible values are: `primary`,`secondary`,`success`,`danger`,`warning`,`info`,`light`,`dark`
106-
`offstyle`|string |"light" |Style of the off toggle. Possible values are: `primary`,`secondary`,`success`,`danger`,`warning`,`info`,`light`,`dark`
107-
`style` |string | |Appends the value to the class attribute of the toggle. This can be used to apply custom styles. Refer to Custom Styles for reference.
108-
`width` |integer |*null* |Sets the width of the toggle. if set to *null*, width will be auto-calculated.
109-
`height` |integer |*null* |Sets the height of the toggle. if set to *null*, height will be auto-calculated.
80+
`onlabel` |string/html|"On" |Text of the on switch button
81+
`offlabel`|string/html|"Off" |Text of the off switch button
82+
`onstyle` |string |"primary" |Style of the on switch button. Possible values are: `primary`,`secondary`,`success`,`danger`,`warning`,`info`,`light`,`dark`
83+
`offstyle`|string |"light" |Style of the off switch button. Possible values are: `primary`,`secondary`,`success`,`danger`,`warning`,`info`,`light`,`dark`
84+
`size` |string |"normal" |Size of the switch button. Possible values are: `large`, `normal`, `small`, `mini`.
85+
`style` |string | |Appends the value to the class attribute of the switch button. This can be used to apply custom styles. Refer to Custom Styles for reference.
86+
`width` |integer |*null* |Sets the width of the switch button. if set to *null*, width will be auto-calculated.
87+
`height` |integer |*null* |Sets the height of the switch button. if set to *null*, height will be auto-calculated.
11088

11189
## Methods
112-
Methods can be used to control toggles directly.
90+
Methods can be used to control switch buttons directly.
11391

11492
```html
115-
<input id="toggle-demo" type="checkbox" data-toggle="toggle">
93+
<input id="switch-demo" type="checkbox" data-toggle="switchButton">
11694
```
11795

118-
Method |Example |Description
119-
-----------|------------------------------------------------|------------------------------------------
120-
initialize | `$('#toggle-demo').bootstrapToggle()` |Initializes the toggle plugin with options
121-
destroy | `$('#toggle-demo').bootstrapToggle('destroy')` |Destroys the toggle
122-
on | `$('#toggle-demo').bootstrapToggle('on')` |Sets the toggle to 'On' state
123-
off | `$('#toggle-demo').bootstrapToggle('off')` |Sets the toggle to 'Off' state
124-
toggle | `$('#toggle-demo').bootstrapToggle('toggle')` |Toggles the state of the toggle on/off
125-
enable | `$('#toggle-demo').bootstrapToggle('enable')` |Enables the toggle
126-
disable | `$('#toggle-demo').bootstrapToggle('disable')` |Disables the toggle
96+
Method |Example |Description
97+
-----------|---------------------------------------------|------------------------------------------
98+
initialize | `$('#switch-demo').switchButton()` |Initializes the switch button plugin with options
99+
destroy | `$('#switch-demo').switchButton('destroy')` |Destroys the switch button
100+
on | `$('#switch-demo').switchButton('on')` |Sets the switch button to 'On' state
101+
off | `$('#switch-demo').switchButton('off')` |Sets the switch button to 'Off' state
102+
toggle | `$('#switch-demo').switchButton('toggle')` |Toggles the state of the switch button on/off
103+
enable | `$('#switch-demo').switchButton('enable')` |Enables the switch button
104+
disable | `$('#switch-demo').switchButton('disable')` |Disables the switch button
127105

128106
# Events
129107

130108
## Event Propagation
131-
Note All events are propagated to and from input element to the toggle.
109+
Note All events are propagated to and from input element to the switch button.
132110

133111
You should listen to events from the `<input type="checkbox">` directly rather than look for custom events.
134112

135113
```html
136-
<input id="toggle-event" type="checkbox" data-toggle="toggle">
114+
<input id="switch-event" type="checkbox" data-toggle="switchButton">
137115
<div id="console-event"></div>
138116
<script>
139117
$(function() {
140-
$('#toggle-event').change(function() {
141-
$('#console-event').html('Toggle: ' + $(this).prop('checked'))
118+
$('#switch-event').change(function() {
119+
$('#console-event').html('Checked?: ' + $(this).prop('checked'))
142120
})
143121
})
144122
</script>
@@ -148,23 +126,23 @@ You should listen to events from the `<input type="checkbox">` directly rather t
148126
This also means that using the API or Input to trigger events will work both ways.
149127

150128
```html
151-
<input id="toggle-trigger" type="checkbox" data-toggle="toggle">
129+
<input id="switch-trigger" type="checkbox" data-toggle="switchButton">
152130
<button class="btn btn-success" onclick="toggleApiOn()" >On by API</button>
153131
<button class="btn btn-danger" onclick="toggleApiOff()">Off by API</button>
154132
<button class="btn btn-success" onclick="toggleInpOn()" >On by Input</button>
155133
<button class="btn btn-danger" onclick="toggleInpOff()">Off by Input</button>
156134
<script>
157135
function toggleApiOn() {
158-
$('#toggle-trigger').bootstrapToggle('on')
136+
$('#switch-trigger').switchButton('on')
159137
}
160138
function toggleApiOff() {
161-
$('#toggle-trigger').bootstrapToggle('off')
139+
$('#switch-trigger').switchButton('off')
162140
}
163141
function toggleInpOn() {
164-
$('#toggle-trigger').prop('checked', true).change()
142+
$('#switch-trigger').prop('checked', true).change()
165143
}
166144
function toggleInpOff() {
167-
$('#toggle-trigger').prop('checked', false).change()
145+
$('#switch-trigger').prop('checked', false).change()
168146
}
169147
</script>
170148
```
271 KB
Loading

0 commit comments

Comments
 (0)