bootstrap5-toggle 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +96 -0
- package/LICENSE +23 -0
- package/README.md +238 -0
- package/css/bootstrap5-toggle.css +160 -0
- package/css/bootstrap5-toggle.min.css +12 -0
- package/css/bootstrap5-toggle.min.css.map +1 -0
- package/debug/.gitignore +2 -0
- package/js/bootstrap5-toggle.ecmas.js +344 -0
- package/js/bootstrap5-toggle.ecmas.min.js +12 -0
- package/js/bootstrap5-toggle.ecmas.min.js.map +1 -0
- package/js/bootstrap5-toggle.js +325 -0
- package/js/bootstrap5-toggle.min.js +12 -0
- package/js/bootstrap5-toggle.min.js.map +1 -0
- package/package.json +55 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## Unreleased
|
|
8
|
+
|
|
9
|
+
## [3.7.0](https://github.com/palcaraz/bootstrap5-toggle/tree/v3.7.00) 2022-08-01
|
|
10
|
+
### [Full Changelog](https://github.com/palcaraz/bootstrap5-toggle/compare/v3.6.0...v3.7.0)
|
|
11
|
+
### Added
|
|
12
|
+
* feat: Distribution of ECMAS lib (#2) by @palcarazm in https://github.com/palcarazm/bootstrap5-toggle/pull/36
|
|
13
|
+
* feat: Support readonly attribute (#35) by @palcarazm in https://github.com/palcarazm/bootstrap5-toggle/pull/37
|
|
14
|
+
* feat: Toggles focusable from the keyboard (#38) by @palcarazm in https://github.com/palcarazm/bootstrap5-toggle/pull/41
|
|
15
|
+
* feat: Switch toggle from keyboard (#39) by @palcarazm in https://github.com/palcarazm/bootstrap5-toggle/pull/42
|
|
16
|
+
* feat: Custom value for on and off state on form submit (#34) by @palcarazm in https://github.com/palcarazm/bootstrap5-toggle/pull/43
|
|
17
|
+
* feat: Tristate toggle (#40) by @palcarazm in https://github.com/palcarazm/bootstrap5-toggle/pull/47
|
|
18
|
+
* feat: Support toggle silent method by @palcarazm in https://github.com/palcarazm/bootstrap5-toggle/pull/30
|
|
19
|
+
### Changed
|
|
20
|
+
* feat: Remove btn-light from handle by @palcarazm in https://github.com/palcarazm/bootstrap5-toggle/pull/21
|
|
21
|
+
* feat: Change default btn off class to secondary by @palcarazm in https://github.com/palcarazm/bootstrap5-toggle/pull/22
|
|
22
|
+
### Fixed
|
|
23
|
+
* fix: Handle border color and btn-light border color by @palcarazm in https://github.com/palcarazm/bootstrap5-toggle/pull/17
|
|
24
|
+
* fix: Render in input-group by @palcarazm in https://github.com/palcarazm/bootstrap5-toggle/pull/29
|
|
25
|
+
|
|
26
|
+
## [3.6.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.6.0) 2019-10-17
|
|
27
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v3.5.0...v3.6.0)
|
|
28
|
+
### Added
|
|
29
|
+
- Added option to change toggle without triggering onChange event (silent toggle) [\#7](https://github.com/gitbrent/bootstrap4-toggle/issue/7) ([aswin1980](https://github.com/aswin1980))
|
|
30
|
+
- Added accessibility properties to labels [\#11](https://github.com/gitbrent/bootstrap4-toggle/issue/11) ([aproquot](https://github.com/aproquot))
|
|
31
|
+
### Changed
|
|
32
|
+
- Fixed URLs in js and css file top comment [\#5](https://github.com/gitbrent/bootstrap4-toggle/issue/5) ([wilecoyte78](https://github.com/wilecoyte78))
|
|
33
|
+
- Disable style is not working [\#18](https://github.com/gitbrent/bootstrap4-toggle/issue/18) ([rychlym](https://github.com/rychlym))
|
|
34
|
+
|
|
35
|
+
## [3.5.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.5.0) 2019-07-02
|
|
36
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v3.4.0...v3.5.0)
|
|
37
|
+
### Added
|
|
38
|
+
- Added ARIA `role="button"` tag to toggle
|
|
39
|
+
- Added `cursor: pointer;` style to toggle
|
|
40
|
+
### Changed
|
|
41
|
+
- Fixed: Touch not working on mobile [\#2](https://github.com/gitbrent/bootstrap4-toggle/issue/2) ([wilecoyte78](https://github.com/wilecoyte78))
|
|
42
|
+
- Updated to Bootstrap version 4.3.1
|
|
43
|
+
- Updated README with better Yarn instructions
|
|
44
|
+
|
|
45
|
+
## [3.4.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.4.0) 2019-01-03
|
|
46
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v3.3.0...v3.4.0)
|
|
47
|
+
### Added
|
|
48
|
+
- Outline button styles are now available
|
|
49
|
+
### Changed
|
|
50
|
+
- Updated to Bootstrap version 4.2.1
|
|
51
|
+
|
|
52
|
+
## [3.3.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.3.0) 2018-12-19
|
|
53
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v3.2.0...v3.3.0)
|
|
54
|
+
### Added
|
|
55
|
+
- New test created to compare core bootstrap sizes to bootstrap4-toggle
|
|
56
|
+
### Changed
|
|
57
|
+
- Introduced new `size` values that mirror bootstrap 4: (`lg`, `sm`, `xs`)
|
|
58
|
+
- Converted all css units from `px` to `rem`
|
|
59
|
+
- Properly added border on `light` button (moved from .toggle class)
|
|
60
|
+
### Removed
|
|
61
|
+
**DEPRECATED** Classic `size` values (`large`, `small`, `mini`)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## [3.2.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.2.0) 2018-11-27
|
|
65
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v3.1.0...v3.2.0)
|
|
66
|
+
### Added
|
|
67
|
+
### Changed
|
|
68
|
+
- Removed permanent `active` state from "Off" label so mouse-over highlighting works the same as "On"
|
|
69
|
+
### Removed
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
## [3.1.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.1.0) 2018-10-25
|
|
74
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v3.0.0...v3.1.0)
|
|
75
|
+
### Added
|
|
76
|
+
- `index.html` includes new section with dark mode colors
|
|
77
|
+
### Changed
|
|
78
|
+
- `index.html` now fully responsive, better menu, rearranged sections
|
|
79
|
+
- Tweaked `border` property to work with all backgrounds and colors
|
|
80
|
+
### Removed
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## [3.0.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.0.0) 2018-10-21
|
|
85
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v2.2.2...v3.0.0)
|
|
86
|
+
### Added
|
|
87
|
+
- Touch support
|
|
88
|
+
### Changed
|
|
89
|
+
- Implements Bootstrap 4 colors/styles
|
|
90
|
+
### Removed
|
|
91
|
+
- Old Bootstrap 2 files
|
|
92
|
+
|
|
93
|
+
[Unreleased]: https://github.com/gitbrent/bootstrap4-toggle/compare/v1.9.0...HEAD
|
|
94
|
+
[3.2.0]: https://github.com/gitbrent/bootstrap4-toggle/compare/v3.1.0...v3.2.0
|
|
95
|
+
[3.1.0]: https://github.com/gitbrent/bootstrap4-toggle/compare/v3.0.0...v3.1.0
|
|
96
|
+
[3.0.0]: https://github.com/gitbrent/bootstrap4-toggle/compare/v2.2.2...v3.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
- Copyright (c) 2011-2014 Min Hur, The New York Times Company
|
|
4
|
+
- Copyright (c) 2018-2019 Brent Ely
|
|
5
|
+
- Copyright (c) 2022 Pablo Alcaraz Martínez
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
[](https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE)
|
|
2
|
+
[](https://github.com/palcarazm/bootstrap5-toggle/releases)
|
|
3
|
+
[](https://www.jsdelivr.com/package/npm/bootstrap5-toggle)
|
|
4
|
+
[](https://www.npmjs.com/package/bootstrap5-toggle)
|
|
5
|
+
[](https://getbootstrap.com/docs/5.2)
|
|
6
|
+
[](https://github.com/palcarazm/bootstrap5-toggle/actions?query=workflow%3A%22Build+Check%22)
|
|
7
|
+
[](https://github.com/palcarazm/bootstrap5-toggle/actions?query=workflow%3A%22Cypress+Tests%22)
|
|
8
|
+
[](https://github.com/palcarazm/bootstrap5-toggle/graphs/contributors)
|
|
9
|
+
[](https://openbase.com/js/bootstrap5-toggle?utm_source=embedded&utm_medium=badge&utm_campaign=rating-badge&utm_term=js/bootstrap5-toggle)
|
|
10
|
+
|
|
11
|
+
# Bootstrap 5 Toggle
|
|
12
|
+
|
|
13
|
+
**Bootstrap 5 Toggle** is a bootstrap plugin/widget that converts checkboxes into toggles.
|
|
14
|
+
|
|
15
|
+
***
|
|
16
|
+
|
|
17
|
+
#### Library Distributions
|
|
18
|
+
Project |Description
|
|
19
|
+
---|---
|
|
20
|
+
[bootstrap5-toggle](https://github.com/palcarazm/bootstrap5-toggle) | Supports bootstrap5 (jQuery and ECMAS distributions)
|
|
21
|
+
[bootstrap5-toggle v3.X.X](https://github.com/palcarazm/bootstrap5-toggle/tree/v3.X.X) | Supports bootstrap4 (jQuery and ECMAS distributions)
|
|
22
|
+
|
|
23
|
+
# Demos
|
|
24
|
+
**Demos and API Docs:** https://palcarazm.github.io/bootstrap5-toggle/v3.X.X
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
<!-- To update TOC run .\node_modules\.bin\doctoc README.md --github -->
|
|
29
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
30
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
31
|
+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
|
|
32
|
+
|
|
33
|
+
- [Installation](#installation)
|
|
34
|
+
- [CDN](#cdn)
|
|
35
|
+
- [jQuery Interface](#jquery-interface)
|
|
36
|
+
- [ECMAS Interface](#ecmas-interface)
|
|
37
|
+
- [Download](#download)
|
|
38
|
+
- [NPM](#npm)
|
|
39
|
+
- [Yarn](#yarn)
|
|
40
|
+
- [Usage](#usage)
|
|
41
|
+
- [Initialize With HTML](#initialize-with-html)
|
|
42
|
+
- [Initialize With Code](#initialize-with-code)
|
|
43
|
+
- [API](#api)
|
|
44
|
+
- [Options](#options)
|
|
45
|
+
- [Methods](#methods)
|
|
46
|
+
- [Events](#events)
|
|
47
|
+
- [Event Propagation](#event-propagation)
|
|
48
|
+
- [Stopping Event Propagation](#stopping-event-propagation)
|
|
49
|
+
- [API vs Input](#api-vs-input)
|
|
50
|
+
- [Collaborators welcom!](#collaborators-welcom)
|
|
51
|
+
|
|
52
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
53
|
+
|
|
54
|
+
**************************************************************************************************
|
|
55
|
+
|
|
56
|
+
# Installation
|
|
57
|
+
|
|
58
|
+
## CDN
|
|
59
|
+
[](https://www.jsdelivr.com/package/npm/bootstrap5-toggle)
|
|
60
|
+
### jQuery Interface
|
|
61
|
+
```html
|
|
62
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@3.7.0/css/bootstrap5-toggle.min.css" rel="stylesheet">
|
|
63
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@3.7.0/js/bootstrap5-toggle.min.js"></script>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### ECMAS Interface
|
|
67
|
+
```html
|
|
68
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@3.7.0/css/bootstrap5-toggle.min.css" rel="stylesheet">
|
|
69
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@3.7.0/js/bootstrap5-toggle.ecmas.min.js"></script>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Download
|
|
73
|
+
[](https://github.com/palcarazm/bootstrap5-toggle/releases/latest)
|
|
74
|
+
|
|
75
|
+
## NPM
|
|
76
|
+
[](https://www.npmjs.com/package/bootstrap5-toggle)
|
|
77
|
+
```ksh
|
|
78
|
+
npm install bootstrap5-toggle
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Yarn
|
|
82
|
+
```ksh
|
|
83
|
+
yarn add bootstrap5-toggle
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
# Usage
|
|
87
|
+
|
|
88
|
+
## Initialize With HTML
|
|
89
|
+
Simply add `data-toggle="toggle"` to automatically convert a plain checkbox into a bootstrap 5 toggle.
|
|
90
|
+
|
|
91
|
+
```html
|
|
92
|
+
<input id="chkToggle" type="checkbox" data-toggle="toggle">
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Initialize With Code
|
|
96
|
+
Toggles can also be initialized via JavaScript code.
|
|
97
|
+
|
|
98
|
+
EX: Initialize id `chkToggle` with a single line of JavaScript.
|
|
99
|
+
```html
|
|
100
|
+
<input id="chkToggle" type="checkbox" checked>
|
|
101
|
+
<script>
|
|
102
|
+
$(function(){
|
|
103
|
+
$('#chkToggle').bootstrapToggle();
|
|
104
|
+
});
|
|
105
|
+
</script>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
# API
|
|
109
|
+
|
|
110
|
+
## Options
|
|
111
|
+
* Options can be passed via data attributes or JavaScript
|
|
112
|
+
* For data attributes, append the option name to `data-` (ex: `data-on="Enabled"`)
|
|
113
|
+
|
|
114
|
+
```html
|
|
115
|
+
<input type="checkbox" data-toggle="toggle" data-on="Enabled" data-off="Disabled">
|
|
116
|
+
<input type="checkbox" id="toggle-two">
|
|
117
|
+
<script>
|
|
118
|
+
$(function() {
|
|
119
|
+
$('#toggle-two').bootstrapToggle({
|
|
120
|
+
on: 'Enabled',
|
|
121
|
+
off: 'Disabled'
|
|
122
|
+
});
|
|
123
|
+
})
|
|
124
|
+
</script>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Name |Type |Default |Description |
|
|
128
|
+
----------|-----------|-----------|----------------------------|
|
|
129
|
+
`on` |string/html|"On" |Text of the on toggle
|
|
130
|
+
`off` |string/html|"Off" |Text of the off toggle
|
|
131
|
+
`size` |string |"normal" |Size of the toggle. Possible values are: `large`, `normal`, `small`, `mini`.
|
|
132
|
+
`onstyle` |string |"primary" |Style of the on toggle. Possible values are: `primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`, `dark` and with `outline-` prefix
|
|
133
|
+
`offstyle`|string |"secondary"|Style of the off toggle. Possible values are: `primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`, `dark` and with `outline-` prefix
|
|
134
|
+
`onvalue` |string |*null* |Sets on state value
|
|
135
|
+
`offvalue`|string |*null* |Sets off state value
|
|
136
|
+
`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.
|
|
137
|
+
`width` |integer |*null* |Sets the width of the toggle. if set to *null*, width will be auto-calculated.
|
|
138
|
+
`height` |integer |*null* |Sets the height of the toggle. if set to *null*, height will be auto-calculated.
|
|
139
|
+
`tabindex`|integer |0 |Sets the tabindex of the toggle.
|
|
140
|
+
`tristate`|boolean |false |Sets tristate support
|
|
141
|
+
|
|
142
|
+
## Methods
|
|
143
|
+
Methods can be used to control toggles directly.
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<input id="toggle-demo" type="checkbox" data-toggle="toggle">
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Method |Example |Description
|
|
150
|
+
-------------|-----------------------------------------------------|------------------------------------------
|
|
151
|
+
initialize | `$('#toggle-demo').bootstrapToggle()` |Initializes the toggle plugin with options
|
|
152
|
+
destroy | `$('#toggle-demo').bootstrapToggle('destroy')` |Destroys the toggle
|
|
153
|
+
on | `$('#toggle-demo').bootstrapToggle('on')` |Sets the toggle to 'On' state
|
|
154
|
+
off | `$('#toggle-demo').bootstrapToggle('off')` |Sets the toggle to 'Off' state
|
|
155
|
+
toggle | `$('#toggle-demo').bootstrapToggle('toggle')` |Toggles the state of the toggle on/off
|
|
156
|
+
enable | `$('#toggle-demo').bootstrapToggle('enable')` |Enables the toggle
|
|
157
|
+
disable | `$('#toggle-demo').bootstrapToggle('disable')` |Disables the toggle
|
|
158
|
+
readonly | `$('#toggle-demo').bootstrapToggle('readonly')` |Disables the toggle but preserve checkbox enabled
|
|
159
|
+
indeterminate| `$('#toggle-demo').bootstrapToggle('indeterminate')`|Sets the toggle to 'indeterminate' state
|
|
160
|
+
determinate | `$('#toggle-demo').bootstrapToggle('determinate')` |Sets the toggle to 'determinate' state
|
|
161
|
+
|
|
162
|
+
# Events
|
|
163
|
+
|
|
164
|
+
## Event Propagation
|
|
165
|
+
Note All events are propagated to and from input element to the toggle.
|
|
166
|
+
|
|
167
|
+
You should listen to events from the `<input type="checkbox">` directly rather than look for custom events.
|
|
168
|
+
|
|
169
|
+
```html
|
|
170
|
+
<input id="toggle-event" type="checkbox" data-toggle="toggle">
|
|
171
|
+
<div id="console-event"></div>
|
|
172
|
+
<script>
|
|
173
|
+
$(function() {
|
|
174
|
+
$('#toggle-event').change(function() {
|
|
175
|
+
$('#console-event').html('Toggle: ' + $(this).prop('checked'))
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
</script>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Stopping Event Propagation
|
|
182
|
+
Passing `true` to the on, off, toggle, determinate and indeterminate methods will enable the silent option to prevent the control from propagating the change event in cases where you want to update the controls on/off state, but do not want to fire the onChange event.
|
|
183
|
+
|
|
184
|
+
```html
|
|
185
|
+
<input id="toggle-silent" type="checkbox" data-toggle="toggle">
|
|
186
|
+
<button class="btn btn-success" onclick="toggleApiOnSilent()" >On by API (silent)</button>
|
|
187
|
+
<button class="btn btn-success" onclick="toggleApiOffSilent()">Off by API (silent)</button>
|
|
188
|
+
<button class="btn btn-warning" onclick="toggleApiOnNotSilent()">On by API (not silent)</button>
|
|
189
|
+
<button class="btn btn-warning" onclick="toggleApiOffNotSilent()">On by API (not silent)</button>
|
|
190
|
+
<script>
|
|
191
|
+
function toggleApiOnSilent() {
|
|
192
|
+
$('#toggle-silent').bootstrapToggle('on', true);
|
|
193
|
+
}
|
|
194
|
+
function toggleApiOffSilent() {
|
|
195
|
+
$('#toggle-silent').bootstrapToggle('off', true);
|
|
196
|
+
}
|
|
197
|
+
function toggleApiOnNotSilent() {
|
|
198
|
+
$('#toggle-silent').bootstrapToggle('on');
|
|
199
|
+
}
|
|
200
|
+
function toggleApiOffNotSilent() {
|
|
201
|
+
$('#toggle-silent').bootstrapToggle('off');
|
|
202
|
+
}
|
|
203
|
+
</script>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## API vs Input
|
|
207
|
+
This also means that using the API or Input to trigger events will work both ways.
|
|
208
|
+
|
|
209
|
+
```html
|
|
210
|
+
<input id="toggle-trigger" type="checkbox" data-toggle="toggle">
|
|
211
|
+
<button class="btn btn-success" onclick="toggleApiOn()" >On by API</button>
|
|
212
|
+
<button class="btn btn-danger" onclick="toggleApiOff()">Off by API</button>
|
|
213
|
+
<button class="btn btn-success" onclick="toggleInpOn()" >On by Input</button>
|
|
214
|
+
<button class="btn btn-danger" onclick="toggleInpOff()">Off by Input</button>
|
|
215
|
+
<script>
|
|
216
|
+
function toggleApiOn() {
|
|
217
|
+
$('#toggle-trigger').bootstrapToggle('on')
|
|
218
|
+
}
|
|
219
|
+
function toggleApiOff() {
|
|
220
|
+
$('#toggle-trigger').bootstrapToggle('off')
|
|
221
|
+
}
|
|
222
|
+
function toggleInpOn() {
|
|
223
|
+
$('#toggle-trigger').prop('checked', true).change()
|
|
224
|
+
}
|
|
225
|
+
function toggleInpOff() {
|
|
226
|
+
$('#toggle-trigger').prop('checked', false).change()
|
|
227
|
+
}
|
|
228
|
+
</script>
|
|
229
|
+
```
|
|
230
|
+
# Collaborators welcom!
|
|
231
|
+
- :sos: ¿Do you need some help? Open a issue in [GitHub help wanted](https://github.com/palcarazm/bootstrap5-toggle/issues/new?assignees=&labels=help+wanted&template=help-wanted.md&title=%5BHELP%5D)
|
|
232
|
+
- :bug: ¿Do you find a bug? Open a issue in [GitHub bug report](https://github.com/palcarazm/bootstrap5-toggle/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D)
|
|
233
|
+
- :bulb: ¿Do you have a great idea? Open a issue in [GitHub feature request](https://github.com/palcarazm/bootstrap5-toggle/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=%5BFEATURE%5D)
|
|
234
|
+
- :computer: ¿Do you know how to fix a bug? Open a pull request in [GitHub pull repuest](https://github.com/palcarazm/bootstrap5-toggle/compare).
|
|
235
|
+
|
|
236
|
+
[](https://github.com/palcarazm/bootstrap5-toggle/graphs/contributors)
|
|
237
|
+
|
|
238
|
+
¿Do you like the project? Give us a :star: in [GitHub](https://github.com/palcarazm/bootstrap5-toggle).
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/* Copyright Notice
|
|
2
|
+
* bootstrap5-toggle v3.7.0
|
|
3
|
+
* https://palcarazm.github.io/bootstrap5-toggle/
|
|
4
|
+
* @author 2011-2014 Min Hur (https://github.com/minhur)
|
|
5
|
+
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
|
|
6
|
+
* @author 2022 Pablo Alcaraz Martínez (https://github.com/palcarazm)
|
|
7
|
+
* @license MIT
|
|
8
|
+
* @see https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* @added 3.0.0: Return support for "*-xs" removed in Bootstrap-4
|
|
14
|
+
* @see: [Comment](https://github.com/twbs/bootstrap/issues/21881#issuecomment-341972830)
|
|
15
|
+
*/
|
|
16
|
+
.btn-group-xs > .btn, .btn-xs {
|
|
17
|
+
padding: .35rem .4rem .25rem .4rem;
|
|
18
|
+
font-size: .875rem;
|
|
19
|
+
line-height: .5;
|
|
20
|
+
border-radius: .2rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.checkbox label .toggle, .checkbox-inline .toggle {
|
|
24
|
+
margin-left: -1.25rem;
|
|
25
|
+
margin-right: .35rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.toggle {
|
|
29
|
+
position: relative;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
}
|
|
32
|
+
.toggle,
|
|
33
|
+
.toggle:focus,
|
|
34
|
+
.toggle:hover{
|
|
35
|
+
background-color: transparent;
|
|
36
|
+
}
|
|
37
|
+
.toggle input[type="checkbox"] {
|
|
38
|
+
display: none;
|
|
39
|
+
}
|
|
40
|
+
.toggle-group {
|
|
41
|
+
position: absolute;
|
|
42
|
+
width: 200%;
|
|
43
|
+
top: 0;
|
|
44
|
+
bottom: 0;
|
|
45
|
+
left: 0;
|
|
46
|
+
transition: left 0.35s;
|
|
47
|
+
-webkit-transition: left 0.35s;
|
|
48
|
+
user-select: none;
|
|
49
|
+
-moz-user-select: none;
|
|
50
|
+
-webkit-user-select: none;
|
|
51
|
+
}
|
|
52
|
+
.toggle.btn:not(.disabled) { cursor: pointer; }
|
|
53
|
+
.toggle.btn.disabled{ cursor:auto; }
|
|
54
|
+
.toggle>.toggle-group>.btn { cursor: inherit; }
|
|
55
|
+
.toggle.off .toggle-group {
|
|
56
|
+
left: -100%;
|
|
57
|
+
}
|
|
58
|
+
.toggle.indeterminate .toggle-group {
|
|
59
|
+
left: -50%;
|
|
60
|
+
}
|
|
61
|
+
.toggle-on {
|
|
62
|
+
position: absolute;
|
|
63
|
+
top: 0;
|
|
64
|
+
bottom: 0;
|
|
65
|
+
left: 0;
|
|
66
|
+
right: 50%;
|
|
67
|
+
margin: 0;
|
|
68
|
+
border: 0;
|
|
69
|
+
border-radius: 0;
|
|
70
|
+
}
|
|
71
|
+
.toggle-off {
|
|
72
|
+
position: absolute;
|
|
73
|
+
top: 0;
|
|
74
|
+
bottom: 0;
|
|
75
|
+
left: 50%;
|
|
76
|
+
right: 0;
|
|
77
|
+
margin: 0;
|
|
78
|
+
border: 0;
|
|
79
|
+
border-radius: 0;
|
|
80
|
+
box-shadow: none; /* Bootstrap 4.0 Support via (Issue #186)[https://github.com/minhur/bootstrap-toggle/issues/186]) */
|
|
81
|
+
}
|
|
82
|
+
.toggle-handle {
|
|
83
|
+
position: relative;
|
|
84
|
+
margin: 0 auto;
|
|
85
|
+
padding-top: 0px;
|
|
86
|
+
padding-bottom: 0px;
|
|
87
|
+
height: 100%;
|
|
88
|
+
width: 0px;
|
|
89
|
+
border-width: 0 1px;
|
|
90
|
+
background-color: #fff;
|
|
91
|
+
border-color: #fff;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Support for input-group
|
|
95
|
+
* @author (bryan-brancotte)[https://github.com/bryan-brancotte]
|
|
96
|
+
* @see https://github.com/gitbrent/bootstrap4-toggle/issues/32#issuecomment-616974580
|
|
97
|
+
*/
|
|
98
|
+
.input-group .toggle-on,
|
|
99
|
+
.input-group .toggle-off{
|
|
100
|
+
position: absolute;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.toggle.btn-outline-primary .toggle-handle {
|
|
104
|
+
background-color: var(--primary);
|
|
105
|
+
border-color: var(--primary);
|
|
106
|
+
}
|
|
107
|
+
.toggle.btn-outline-secondary .toggle-handle {
|
|
108
|
+
background-color: var(--secondary);
|
|
109
|
+
border-color: var(--secondary);
|
|
110
|
+
}
|
|
111
|
+
.toggle.btn-outline-success .toggle-handle {
|
|
112
|
+
background-color: var(--success);
|
|
113
|
+
border-color: var(--success);
|
|
114
|
+
}
|
|
115
|
+
.toggle.btn-outline-danger .toggle-handle {
|
|
116
|
+
background-color: var(--danger);
|
|
117
|
+
border-color: var(--danger);
|
|
118
|
+
}
|
|
119
|
+
.toggle.btn-outline-warning .toggle-handle {
|
|
120
|
+
background-color: var(--warning);
|
|
121
|
+
border-color: var(--warning);
|
|
122
|
+
}
|
|
123
|
+
.toggle.btn-outline-info .toggle-handle {
|
|
124
|
+
background-color: var(--info);
|
|
125
|
+
border-color: var(--info);
|
|
126
|
+
}
|
|
127
|
+
.toggle.btn-outline-light .toggle-handle {
|
|
128
|
+
background-color: var(--light);
|
|
129
|
+
border-color: var(--light);
|
|
130
|
+
}
|
|
131
|
+
.toggle.btn-outline-dark .toggle-handle {
|
|
132
|
+
background-color: var(--dark);
|
|
133
|
+
border-color: var(--dark);
|
|
134
|
+
}
|
|
135
|
+
.toggle[class*="btn-outline"]:hover .toggle-handle {
|
|
136
|
+
background-color: var(--light);
|
|
137
|
+
opacity: 0.5;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* NOTE: Must come first, so classes below override as needed */
|
|
141
|
+
/* [default] (bootstrap-4.1.3 - .btn - h:38px) */
|
|
142
|
+
.toggle.btn { min-width: 3.7rem; min-height: 2.15rem; }
|
|
143
|
+
.toggle-on.btn { padding-right: 1.5rem; }
|
|
144
|
+
.toggle-off.btn { padding-left: 1.5rem; }
|
|
145
|
+
|
|
146
|
+
/* `lg` (bootstrap-4.1.3 - .btn - h:48px) */
|
|
147
|
+
.toggle.btn-lg { min-width: 5rem; min-height: 2.815rem; }
|
|
148
|
+
.toggle-on.btn-lg { padding-right: 2rem; }
|
|
149
|
+
.toggle-off.btn-lg { padding-left: 2rem; }
|
|
150
|
+
.toggle-handle.btn-lg { width: 2.5rem; }
|
|
151
|
+
|
|
152
|
+
/* `sm` (bootstrap-4.1.3 - .btn - h:31px) */
|
|
153
|
+
.toggle.btn-sm { min-width: 3.125rem; min-height: 1.938rem; }
|
|
154
|
+
.toggle-on.btn-sm { padding-right: 1rem; }
|
|
155
|
+
.toggle-off.btn-sm { padding-left: 1rem; }
|
|
156
|
+
|
|
157
|
+
/* `xs` (bootstrap-3.3 - .btn - h:22px) */
|
|
158
|
+
.toggle.btn-xs { min-width: 2.19rem; min-height: 1.375rem; }
|
|
159
|
+
.toggle-on.btn-xs { padding-right: .8rem; }
|
|
160
|
+
.toggle-off.btn-xs { padding-left: .8rem; }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* Copyright Notice
|
|
2
|
+
* bootstrap5-toggle v3.7.0
|
|
3
|
+
* https://palcarazm.github.io/bootstrap5-toggle/
|
|
4
|
+
* @author 2011-2014 Min Hur (https://github.com/minhur)
|
|
5
|
+
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
|
|
6
|
+
* @author 2022 Pablo Alcaraz Martínez (https://github.com/palcarazm)
|
|
7
|
+
* @license MIT
|
|
8
|
+
* @see https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
.btn-group-xs>.btn,.btn-xs{padding:.35rem .4rem .25rem .4rem;font-size:.875rem;line-height:.5;border-radius:.2rem}.checkbox label .toggle,.checkbox-inline .toggle{margin-left:-1.25rem;margin-right:.35rem}.toggle{position:relative;overflow:hidden}.toggle,.toggle:focus,.toggle:hover{background-color:transparent}.toggle input[type=checkbox]{display:none}.toggle-group{position:absolute;width:200%;top:0;bottom:0;left:0;transition:left .35s;-webkit-transition:left .35s;user-select:none;-moz-user-select:none;-webkit-user-select:none}.toggle.btn:not(.disabled){cursor:pointer}.toggle.btn.disabled{cursor:auto}.toggle>.toggle-group>.btn{cursor:inherit}.toggle.off .toggle-group{left:-100%}.toggle.indeterminate .toggle-group{left:-50%}.toggle-on{position:absolute;top:0;bottom:0;left:0;right:50%;margin:0;border:0;border-radius:0}.toggle-off{position:absolute;top:0;bottom:0;left:50%;right:0;margin:0;border:0;border-radius:0;box-shadow:none}.toggle-handle{position:relative;margin:0 auto;padding-top:0;padding-bottom:0;height:100%;width:0;border-width:0 1px;background-color:#fff;border-color:#fff}.input-group .toggle-off,.input-group .toggle-on{position:absolute}.toggle.btn-outline-primary .toggle-handle{background-color:var(--primary);border-color:var(--primary)}.toggle.btn-outline-secondary .toggle-handle{background-color:var(--secondary);border-color:var(--secondary)}.toggle.btn-outline-success .toggle-handle{background-color:var(--success);border-color:var(--success)}.toggle.btn-outline-danger .toggle-handle{background-color:var(--danger);border-color:var(--danger)}.toggle.btn-outline-warning .toggle-handle{background-color:var(--warning);border-color:var(--warning)}.toggle.btn-outline-info .toggle-handle{background-color:var(--info);border-color:var(--info)}.toggle.btn-outline-light .toggle-handle{background-color:var(--light);border-color:var(--light)}.toggle.btn-outline-dark .toggle-handle{background-color:var(--dark);border-color:var(--dark)}.toggle[class*=btn-outline]:hover .toggle-handle{background-color:var(--light);opacity:.5}.toggle.btn{min-width:3.7rem;min-height:2.15rem}.toggle-on.btn{padding-right:1.5rem}.toggle-off.btn{padding-left:1.5rem}.toggle.btn-lg{min-width:5rem;min-height:2.815rem}.toggle-on.btn-lg{padding-right:2rem}.toggle-off.btn-lg{padding-left:2rem}.toggle-handle.btn-lg{width:2.5rem}.toggle.btn-sm{min-width:3.125rem;min-height:1.938rem}.toggle-on.btn-sm{padding-right:1rem}.toggle-off.btn-sm{padding-left:1rem}.toggle.btn-xs{min-width:2.19rem;min-height:1.375rem}.toggle-on.btn-xs{padding-right:.8rem}.toggle-off.btn-xs{padding-left:.8rem}
|
|
12
|
+
/*# sourceMappingURL=bootstrap5-toggle.min.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["css\\bootstrap5-toggle.css"],"names":[],"mappings":"AAeA,mBAAsB,QACrB,QAAS,OAAO,MAAM,OAAO,MAC7B,UAAW,QACX,YAAa,GACb,cAAe,MAGhB,wBAAyB,yBACxB,YAAa,SACb,aAAc,OAGf,QACC,SAAU,SACV,SAAU,OAEX,QACA,cACA,cACA,iBAAkB,YAElB,6BACC,QAAS,KAEV,cACC,SAAU,SACV,MAAO,KACP,IAAK,EACL,OAAQ,EACR,KAAM,EACN,WAAY,KAAK,KACjB,mBAAoB,KAAK,KACzB,YAAa,KACb,iBAAkB,KAClB,oBAAqB,KAEtB,2BAA6B,OAAQ,QACrC,qBAAsB,OAAO,KAC7B,2BAA6B,OAAQ,QACrC,0BACC,KAAM,MAEP,oCACC,KAAM,KAEP,WACC,SAAU,SACV,IAAK,EACL,OAAQ,EACR,KAAM,EACN,MAAO,IACP,OAAQ,EACR,OAAQ,EACR,cAAe,EAEhB,YACC,SAAU,SACV,IAAK,EACL,OAAQ,EACR,KAAM,IACN,MAAO,EACP,OAAQ,EACR,OAAQ,EACR,cAAe,EACf,WAAY,KAEb,eACC,SAAU,SACV,OAAQ,EAAE,KACV,YAAa,EACb,eAAgB,EAChB,OAAQ,KACR,MAAO,EACP,aAAc,EAAE,IAChB,iBAAkB,KAClB,aAAc,KAQf,yBADA,wBAEI,SAAU,SAGd,2CACC,iBAAkB,eAClB,aAAc,eAEf,6CACC,iBAAkB,iBAClB,aAAc,iBAEf,2CACC,iBAAkB,eAClB,aAAc,eAEf,0CACC,iBAAkB,cAClB,aAAc,cAEf,2CACC,iBAAkB,eAClB,aAAc,eAEf,wCACC,iBAAkB,YAClB,aAAc,YAEf,yCACC,iBAAkB,aAClB,aAAc,aAEf,wCACC,iBAAkB,YAClB,aAAc,YAEf,iDACC,iBAAkB,aAClB,QAAS,GAKV,YAAc,UAAW,OAAQ,WAAY,QAC7C,eAAiB,cAAe,OAChC,gBAAkB,aAAc,OAGhC,eAAiB,UAAW,KAAM,WAAY,SAC9C,kBAAoB,cAAe,KACnC,mBAAqB,aAAc,KACnC,sBAAwB,MAAO,OAG/B,eAAiB,UAAW,SAAU,WAAY,SAClD,kBAAoB,cAAe,KACnC,mBAAqB,aAAc,KAGnC,eAAiB,UAAW,QAAS,WAAY,SACjD,kBAAoB,cAAe,MACnC,mBAAqB,aAAc"}
|
package/debug/.gitignore
ADDED