bootstrap5-toggle 4.1.0 → 4.2.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 +89 -0
- package/README.md +14 -9
- package/css/bootstrap5-toggle.css +14 -9
- package/css/bootstrap5-toggle.min.css +7 -6
- package/css/bootstrap5-toggle.min.css.map +1 -0
- package/js/bootstrap5-toggle.js +29 -19
- package/js/bootstrap5-toggle.min.js +11 -12
- package/js/bootstrap5-toggle.min.js.map +1 -1
- package/package.json +10 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
## [4.1.0](https://github.com/palcaraz/bootstrap5-toggle/tree/v4.1.0) 2022-06-30
|
|
10
|
+
### [Full Changelog](https://github.com/palcaraz/bootstrap4-toggle/compare/v4.0.0...v4.1.0)
|
|
11
|
+
### Added
|
|
12
|
+
- feat: support for npm and yarn
|
|
13
|
+
|
|
14
|
+
## [4.0.0](https://github.com/palcaraz/bootstrap5-toggle/tree/v4.0.0) 2022-06-30
|
|
15
|
+
### [Full Changelog](https://github.com/palcaraz/bootstrap4-toggle/compare/v3.6.0...v4.0.0)
|
|
16
|
+
### Added
|
|
17
|
+
- feat: support for Boostrap 5
|
|
18
|
+
|
|
19
|
+
## [3.6.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.6.0) 2019-10-17
|
|
20
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v3.5.0...v3.6.0)
|
|
21
|
+
### Added
|
|
22
|
+
- 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))
|
|
23
|
+
- Added accessibility properties to labels [\#11](https://github.com/gitbrent/bootstrap4-toggle/issue/11) ([aproquot](https://github.com/aproquot))
|
|
24
|
+
### Changed
|
|
25
|
+
- Fixed URLs in js and css file top comment [\#5](https://github.com/gitbrent/bootstrap4-toggle/issue/5) ([wilecoyte78](https://github.com/wilecoyte78))
|
|
26
|
+
- Disable style is not working [\#18](https://github.com/gitbrent/bootstrap4-toggle/issue/18) ([rychlym](https://github.com/rychlym))
|
|
27
|
+
|
|
28
|
+
## [3.5.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.5.0) 2019-07-02
|
|
29
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v3.4.0...v3.5.0)
|
|
30
|
+
### Added
|
|
31
|
+
- Added ARIA `role="button"` tag to toggle
|
|
32
|
+
- Added `cursor: pointer;` style to toggle
|
|
33
|
+
### Changed
|
|
34
|
+
- Fixed: Touch not working on mobile [\#2](https://github.com/gitbrent/bootstrap4-toggle/issue/2) ([wilecoyte78](https://github.com/wilecoyte78))
|
|
35
|
+
- Updated to Bootstrap version 4.3.1
|
|
36
|
+
- Updated README with better Yarn instructions
|
|
37
|
+
|
|
38
|
+
## [3.4.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.4.0) 2019-01-03
|
|
39
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v3.3.0...v3.4.0)
|
|
40
|
+
### Added
|
|
41
|
+
- Outline button styles are now available
|
|
42
|
+
### Changed
|
|
43
|
+
- Updated to Bootstrap version 4.2.1
|
|
44
|
+
|
|
45
|
+
## [3.3.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.3.0) 2018-12-19
|
|
46
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v3.2.0...v3.3.0)
|
|
47
|
+
### Added
|
|
48
|
+
- New test created to compare core bootstrap sizes to bootstrap4-toggle
|
|
49
|
+
### Changed
|
|
50
|
+
- Introduced new `size` values that mirror bootstrap 4: (`lg`, `sm`, `xs`)
|
|
51
|
+
- Converted all css units from `px` to `rem`
|
|
52
|
+
- Properly added border on `light` button (moved from .toggle class)
|
|
53
|
+
### Removed
|
|
54
|
+
**DEPRECATED** Classic `size` values (`large`, `small`, `mini`)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## [3.2.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.2.0) 2018-11-27
|
|
58
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v3.1.0...v3.2.0)
|
|
59
|
+
### Added
|
|
60
|
+
### Changed
|
|
61
|
+
- Removed permanent `active` state from "Off" label so mouse-over highlighting works the same as "On"
|
|
62
|
+
### Removed
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## [3.1.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.1.0) 2018-10-25
|
|
67
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v3.0.0...v3.1.0)
|
|
68
|
+
### Added
|
|
69
|
+
- `index.html` includes new section with dark mode colors
|
|
70
|
+
### Changed
|
|
71
|
+
- `index.html` now fully responsive, better menu, rearranged sections
|
|
72
|
+
- Tweaked `border` property to work with all backgrounds and colors
|
|
73
|
+
### Removed
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
## [3.0.0](https://github.com/gitbrent/bootstrap4-toggle/tree/v3.0.0) 2018-10-21
|
|
78
|
+
### [Full Changelog](https://github.com/gitbrent/bootstrap4-toggle/compare/v2.2.2...v3.0.0)
|
|
79
|
+
### Added
|
|
80
|
+
- Touch support
|
|
81
|
+
### Changed
|
|
82
|
+
- Implements Bootstrap 4 colors/styles
|
|
83
|
+
### Removed
|
|
84
|
+
- Old Bootstrap 2 files
|
|
85
|
+
|
|
86
|
+
[Unreleased]: https://github.com/gitbrent/bootstrap4-toggle/compare/v1.9.0...HEAD
|
|
87
|
+
[3.2.0]: https://github.com/gitbrent/bootstrap4-toggle/compare/v3.1.0...v3.2.0
|
|
88
|
+
[3.1.0]: https://github.com/gitbrent/bootstrap4-toggle/compare/v3.0.0...v3.1.0
|
|
89
|
+
[3.0.0]: https://github.com/gitbrent/bootstrap4-toggle/compare/v2.2.2...v3.0.0
|
package/README.md
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
[](https://github.com/palcarazm/bootstrap5-toggle/releases/latest)
|
|
2
1
|
[](https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE)
|
|
3
|
-
[](https://github.com/palcarazm/bootstrap5-toggle/releases/latest)
|
|
3
|
+
[](https://www.jsdelivr.com/package/npm/bootstrap5-toggle)
|
|
4
|
+
[](https://www.npmjs.com/package/bootstrap5-toggle)
|
|
5
|
+
[](https://getbootstrap.com/docs/5.1)
|
|
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)
|
|
7
10
|
|
|
8
11
|
# Bootstrap 5 Toggle
|
|
9
12
|
|
|
@@ -14,7 +17,7 @@
|
|
|
14
17
|
#### Library Distributions
|
|
15
18
|
Project |Description
|
|
16
19
|
---|---
|
|
17
|
-
[bootstrap5-toggle](https://github.com/palcarazm/bootstrap5-toggle)
|
|
20
|
+
[bootstrap5-toggle](https://github.com/palcarazm/bootstrap5-toggle) | Supports bootstrap5 (requires jQuery)
|
|
18
21
|
[bootstrap4-toggle](https://github.com/gitbrent/bootstrap4-toggle) | Supports bootstrap4 (requires jQuery)
|
|
19
22
|
[bootstrap-switch-button](https://github.com/gitbrent/bootstrap-switch-button) | Supports bootstrap4+ (ES6 class, no dependencies)
|
|
20
23
|
[bootstrap-switch-button-react](https://github.com/gitbrent/bootstrap-switch-button-react) | Supports bootstrap4+ (React component, no dependencies)
|
|
@@ -54,15 +57,17 @@ Project |Description
|
|
|
54
57
|
# Installation
|
|
55
58
|
|
|
56
59
|
## CDN
|
|
60
|
+
[](https://www.jsdelivr.com/package/npm/bootstrap5-toggle)
|
|
57
61
|
```html
|
|
58
|
-
<link href="https://cdn.jsdelivr.net/
|
|
59
|
-
<script src="https://cdn.jsdelivr.net/
|
|
62
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@4.2.0/css/bootstrap5-toggle.min.css" rel="stylesheet">
|
|
63
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@4.2.0/js/bootstrap5-toggle.min.js"></script>
|
|
60
64
|
```
|
|
61
65
|
|
|
62
66
|
## Download
|
|
63
67
|
[](https://github.com/palcarazm/bootstrap5-toggle/releases/latest)
|
|
64
68
|
|
|
65
69
|
## NPM
|
|
70
|
+
[](https://www.npmjs.com/package/bootstrap5-toggle)
|
|
66
71
|
```ksh
|
|
67
72
|
npm install bootstrap5-toggle
|
|
68
73
|
```
|
|
@@ -161,7 +166,7 @@ You should listen to events from the `<input type="checkbox">` directly rather t
|
|
|
161
166
|
```
|
|
162
167
|
|
|
163
168
|
## Stopping Event Propagation
|
|
164
|
-
Passing `true` to the on
|
|
169
|
+
Passing `true` to the on, off and toggle methods will enable the silent option to prevent the control from propagating the change event in
|
|
165
170
|
cases where you want to update the controls on/off state, but do not want to fire the onChange event.
|
|
166
171
|
|
|
167
172
|
```html
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
1
|
+
/* Copyright Notice
|
|
2
|
+
* bootstrap5-toggle v4.2.0
|
|
3
3
|
* https://palcarazm.github.io/bootstrap5-toggle/
|
|
4
|
-
*
|
|
5
4
|
* @author 2011-2014 Min Hur (https://github.com/minhur)
|
|
6
5
|
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
|
|
7
6
|
* @author 2022 Pablo Alcaraz Martínez (https://github.com/palcarazm)
|
|
8
|
-
* @
|
|
7
|
+
* @license MIT
|
|
9
8
|
* @see https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE
|
|
10
|
-
* @preserve
|
|
11
9
|
*/
|
|
12
10
|
|
|
11
|
+
|
|
13
12
|
/*
|
|
14
13
|
* @added 3.0.0: Return support for "*-xs" removed in Bootstrap-4
|
|
15
14
|
* @see: [Comment](https://github.com/twbs/bootstrap/issues/21881#issuecomment-341972830)
|
|
@@ -30,10 +29,6 @@
|
|
|
30
29
|
position: relative;
|
|
31
30
|
overflow: hidden;
|
|
32
31
|
}
|
|
33
|
-
.toggle.btn.btn-light, .toggle.btn.btn-outline-light {
|
|
34
|
-
/* bootstrap-4 - add a border so toggle is delineated */
|
|
35
|
-
border-color: rgba(0, 0, 0, .15);
|
|
36
|
-
}
|
|
37
32
|
.toggle input[type="checkbox"] {
|
|
38
33
|
display: none;
|
|
39
34
|
}
|
|
@@ -83,6 +78,16 @@
|
|
|
83
78
|
width: 0px;
|
|
84
79
|
border-width: 0 1px;
|
|
85
80
|
background-color: #fff;
|
|
81
|
+
border-color: #fff;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Support for input-group
|
|
85
|
+
* @author (bryan-brancotte)[https://github.com/bryan-brancotte]
|
|
86
|
+
* @see https://github.com/gitbrent/bootstrap4-toggle/issues/32#issuecomment-616974580
|
|
87
|
+
*/
|
|
88
|
+
.input-group .toggle-on,
|
|
89
|
+
.input-group .toggle-off{
|
|
90
|
+
position: absolute;
|
|
86
91
|
}
|
|
87
92
|
|
|
88
93
|
.toggle.btn-outline-primary .toggle-handle {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
1
|
+
/* Copyright Notice
|
|
2
|
+
* bootstrap5-toggle v4.2.0
|
|
3
3
|
* https://palcarazm.github.io/bootstrap5-toggle/
|
|
4
|
-
*
|
|
5
4
|
* @author 2011-2014 Min Hur (https://github.com/minhur)
|
|
6
5
|
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
|
|
7
6
|
* @author 2022 Pablo Alcaraz Martínez (https://github.com/palcarazm)
|
|
8
|
-
* @
|
|
7
|
+
* @license MIT
|
|
9
8
|
* @see https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE
|
|
10
|
-
|
|
11
|
-
|
|
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 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-group label,.toggle-group span{cursor:pointer}.toggle.off .toggle-group{left:-100%}.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(--bs-primary);border-color:var(--bs-primary)}.toggle.btn-outline-secondary .toggle-handle{background-color:var(--bs-secondary);border-color:var(--bs-secondary)}.toggle.btn-outline-success .toggle-handle{background-color:var(--bs-success);border-color:var(--bs-success)}.toggle.btn-outline-danger .toggle-handle{background-color:var(--bs-danger);border-color:var(--bs-danger)}.toggle.btn-outline-warning .toggle-handle{background-color:var(--bs-warning);border-color:var(--bs-warning)}.toggle.btn-outline-info .toggle-handle{background-color:var(--bs-info);border-color:var(--bs-info)}.toggle.btn-outline-light .toggle-handle{background-color:var(--bs-light);border-color:var(--bs-light)}.toggle.btn-outline-dark .toggle-handle{background-color:var(--bs-dark);border-color:var(--bs-dark)}.toggle[class*=btn-outline]:hover .toggle-handle{background-color:var(--bs-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,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,oBAAqB,mBAAqB,OAAQ,QAClD,0BACC,KAAM,MAEP,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,kBAClB,aAAc,kBAEf,6CACC,iBAAkB,oBAClB,aAAc,oBAEf,2CACC,iBAAkB,kBAClB,aAAc,kBAEf,0CACC,iBAAkB,iBAClB,aAAc,iBAEf,2CACC,iBAAkB,kBAClB,aAAc,kBAEf,wCACC,iBAAkB,eAClB,aAAc,eAEf,yCACC,iBAAkB,gBAClB,aAAc,gBAEf,wCACC,iBAAkB,eAClB,aAAc,eAEf,iDACC,iBAAkB,gBAClB,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/js/bootstrap5-toggle.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
1
|
+
/* Copyright Notice
|
|
2
|
+
* bootstrap5-toggle v4.2.0
|
|
3
3
|
* https://palcarazm.github.io/bootstrap5-toggle/
|
|
4
|
-
*
|
|
5
4
|
* @author 2011-2014 Min Hur (https://github.com/minhur)
|
|
6
5
|
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
|
|
7
6
|
* @author 2022 Pablo Alcaraz Martínez (https://github.com/palcarazm)
|
|
8
|
-
* @
|
|
7
|
+
* @license MIT
|
|
9
8
|
* @see https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE
|
|
10
|
-
* @preserve
|
|
11
9
|
*/
|
|
12
10
|
|
|
11
|
+
|
|
13
12
|
+function ($) {
|
|
14
13
|
'use strict';
|
|
15
14
|
|
|
@@ -22,13 +21,11 @@
|
|
|
22
21
|
this.render()
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
Toggle.VERSION = '3.7.0-beta'
|
|
26
|
-
|
|
27
24
|
Toggle.DEFAULTS = {
|
|
28
25
|
on: 'On',
|
|
29
26
|
off: 'Off',
|
|
30
27
|
onstyle: 'primary',
|
|
31
|
-
offstyle: '
|
|
28
|
+
offstyle: 'secondary',
|
|
32
29
|
size: 'normal',
|
|
33
30
|
style: '',
|
|
34
31
|
width: null,
|
|
@@ -51,16 +48,29 @@
|
|
|
51
48
|
Toggle.prototype.render = function () {
|
|
52
49
|
this._onstyle = 'btn-' + this.options.onstyle
|
|
53
50
|
this._offstyle = 'btn-' + this.options.offstyle
|
|
54
|
-
var size
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
var size;
|
|
52
|
+
switch (this.options.size ) {
|
|
53
|
+
case 'large':
|
|
54
|
+
case 'lg':
|
|
55
|
+
size = 'btn-lg';
|
|
56
|
+
break;
|
|
57
|
+
case 'small':
|
|
58
|
+
case 'sm':
|
|
59
|
+
size = 'btn-sm';
|
|
60
|
+
break;
|
|
61
|
+
case 'mini':
|
|
62
|
+
case 'xs':
|
|
63
|
+
size = 'btn-xs';
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
size = ''
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
59
69
|
var $toggleOn = $('<label for="'+ this.$element.prop('id') +'" class="btn">').html(this.options.on)
|
|
60
70
|
.addClass(this._onstyle + ' ' + size)
|
|
61
71
|
var $toggleOff = $('<label for="'+ this.$element.prop('id') +'" class="btn">').html(this.options.off)
|
|
62
72
|
.addClass(this._offstyle + ' ' + size)
|
|
63
|
-
var $toggleHandle = $('<span class="toggle-handle btn
|
|
73
|
+
var $toggleHandle = $('<span class="toggle-handle btn">')
|
|
64
74
|
.addClass(size)
|
|
65
75
|
var $toggleGroup = $('<div class="toggle-group">')
|
|
66
76
|
.append($toggleOn, $toggleOff, $toggleHandle)
|
|
@@ -90,19 +100,19 @@
|
|
|
90
100
|
this.trigger(true)
|
|
91
101
|
}
|
|
92
102
|
|
|
93
|
-
Toggle.prototype.toggle = function () {
|
|
94
|
-
if (this.$element.prop('checked')) this.off()
|
|
95
|
-
else this.on()
|
|
103
|
+
Toggle.prototype.toggle = function (silent = false) {
|
|
104
|
+
if (this.$element.prop('checked')) this.off(silent)
|
|
105
|
+
else this.on(silent)
|
|
96
106
|
}
|
|
97
107
|
|
|
98
|
-
Toggle.prototype.on = function (silent) {
|
|
108
|
+
Toggle.prototype.on = function (silent = false) {
|
|
99
109
|
if (this.$element.prop('disabled')) return false
|
|
100
110
|
this.$toggle.removeClass(this._offstyle + ' off').addClass(this._onstyle)
|
|
101
111
|
this.$element.prop('checked', true)
|
|
102
112
|
if (!silent) this.trigger()
|
|
103
113
|
}
|
|
104
114
|
|
|
105
|
-
Toggle.prototype.off = function (silent) {
|
|
115
|
+
Toggle.prototype.off = function (silent = false) {
|
|
106
116
|
if (this.$element.prop('disabled')) return false
|
|
107
117
|
this.$toggle.removeClass(this._onstyle).addClass(this._offstyle + ' off')
|
|
108
118
|
this.$element.prop('checked', false)
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* https://palcarazm.github.io/bootstrap5-toggle/
|
|
4
|
-
*
|
|
5
|
-
* @author
|
|
6
|
-
* @author
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
!function(l){"use strict";function i(t,e){this.$element=l(t),this.options=l.extend({},this.defaults(),e),this.render()}i.VERSION="3.7.0-beta",i.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"light",size:"normal",style:"",width:null,height:null},i.prototype.defaults=function(){return{on:this.$element.attr("data-on")||i.DEFAULTS.on,off:this.$element.attr("data-off")||i.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||i.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||i.DEFAULTS.offstyle,size:this.$element.attr("data-size")||i.DEFAULTS.size,style:this.$element.attr("data-style")||i.DEFAULTS.style,width:this.$element.attr("data-width")||i.DEFAULTS.width,height:this.$element.attr("data-height")||i.DEFAULTS.height}},i.prototype.render=function(){this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle;var t="large"===this.options.size||"lg"===this.options.size?"btn-lg":"small"===this.options.size||"sm"===this.options.size?"btn-sm":"mini"===this.options.size||"xs"===this.options.size?"btn-xs":"",e=l('<label for="'+this.$element.prop("id")+'" class="btn">').html(this.options.on).addClass(this._onstyle+" "+t),s=l('<label for="'+this.$element.prop("id")+'" class="btn">').html(this.options.off).addClass(this._offstyle+" "+t),o=l('<span class="toggle-handle btn btn-light">').addClass(t),i=l('<div class="toggle-group">').append(e,s,o),t=l('<div class="toggle btn" data-toggle="toggle" role="button">').addClass(this.$element.prop("checked")?this._onstyle:this._offstyle+" off").addClass(t).addClass(this.options.style),t=(this.$element.wrap(t),l.extend(this,{$toggle:this.$element.parent(),$toggleOn:e,$toggleOff:s,$toggleGroup:i}),this.$toggle.append(i),this.options.width||Math.max(e.outerWidth(),s.outerWidth())+o.outerWidth()/2),i=this.options.height||Math.max(e.outerHeight(),s.outerHeight());e.addClass("toggle-on"),s.addClass("toggle-off"),this.$toggle.css({width:t,height:i}),this.options.height&&(e.css("line-height",e.height()+"px"),s.css("line-height",s.height()+"px")),this.update(!0),this.trigger(!0)},i.prototype.toggle=function(){this.$element.prop("checked")?this.off():this.on()},i.prototype.on=function(t){if(this.$element.prop("disabled"))return!1;this.$toggle.removeClass(this._offstyle+" off").addClass(this._onstyle),this.$element.prop("checked",!0),t||this.trigger()},i.prototype.off=function(t){if(this.$element.prop("disabled"))return!1;this.$toggle.removeClass(this._onstyle).addClass(this._offstyle+" off"),this.$element.prop("checked",!1),t||this.trigger()},i.prototype.enable=function(){this.$toggle.removeClass("disabled"),this.$toggle.removeAttr("disabled"),this.$element.prop("disabled",!1)},i.prototype.disable=function(){this.$toggle.addClass("disabled"),this.$toggle.attr("disabled","disabled"),this.$element.prop("disabled",!0)},i.prototype.update=function(t){this.$element.prop("disabled")?this.disable():this.enable(),this.$element.prop("checked")?this.on(t):this.off(t)},i.prototype.trigger=function(t){this.$element.off("change.bs.toggle"),t||this.$element.change(),this.$element.on("change.bs.toggle",l.proxy(function(){this.update()},this))},i.prototype.destroy=function(){this.$element.off("change.bs.toggle"),this.$toggleGroup.remove(),this.$element.removeData("bs.toggle"),this.$element.unwrap()};var t=l.fn.bootstrapToggle;l.fn.bootstrapToggle=function(s){var o=Array.prototype.slice.call(arguments,1)[0];return this.each(function(){var t=l(this),e=t.data("bs.toggle");e||t.data("bs.toggle",e=new i(this,"object"==typeof s&&s)),"string"==typeof s&&e[s]&&"boolean"==typeof o?e[s](o):"string"==typeof s&&e[s]&&e[s]()})},l.fn.bootstrapToggle.Constructor=i,l.fn.toggle.noConflict=function(){return l.fn.bootstrapToggle=t,this},l(function(){l("input[type=checkbox][data-toggle^=toggle]").bootstrapToggle()}),l(document).on("click.bs.toggle","div[data-toggle^=toggle]",function(t){l(this).find("input[type=checkbox]").bootstrapToggle("toggle"),t.preventDefault()})}(jQuery);
|
|
1
|
+
/* Copyright Notice
|
|
2
|
+
* bootstrap5-toggle v4.2.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
|
+
!function(n){"use strict";function i(t,e){this.$element=n(t),this.options=n.extend({},this.defaults(),e),this.render()}i.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"secondary",size:"normal",style:"",width:null,height:null},i.prototype.defaults=function(){return{on:this.$element.attr("data-on")||i.DEFAULTS.on,off:this.$element.attr("data-off")||i.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||i.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||i.DEFAULTS.offstyle,size:this.$element.attr("data-size")||i.DEFAULTS.size,style:this.$element.attr("data-style")||i.DEFAULTS.style,width:this.$element.attr("data-width")||i.DEFAULTS.width,height:this.$element.attr("data-height")||i.DEFAULTS.height}},i.prototype.render=function(){var t;switch(this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle,this.options.size){case"large":case"lg":t="btn-lg";break;case"small":case"sm":t="btn-sm";break;case"mini":case"xs":t="btn-xs";break;default:t=""}var e=n('<label for="'+this.$element.prop("id")+'" class="btn">').html(this.options.on).addClass(this._onstyle+" "+t),s=n('<label for="'+this.$element.prop("id")+'" class="btn">').html(this.options.off).addClass(this._offstyle+" "+t),o=n('<span class="toggle-handle btn">').addClass(t),i=n('<div class="toggle-group">').append(e,s,o),l=n('<div class="toggle btn" data-toggle="toggle" role="button">').addClass(this.$element.prop("checked")?this._onstyle:this._offstyle+" off").addClass(t).addClass(this.options.style),l=(this.$element.wrap(l),n.extend(this,{$toggle:this.$element.parent(),$toggleOn:e,$toggleOff:s,$toggleGroup:i}),this.$toggle.append(i),this.options.width||Math.max(e.outerWidth(),s.outerWidth())+o.outerWidth()/2),i=this.options.height||Math.max(e.outerHeight(),s.outerHeight());e.addClass("toggle-on"),s.addClass("toggle-off"),this.$toggle.css({width:l,height:i}),this.options.height&&(e.css("line-height",e.height()+"px"),s.css("line-height",s.height()+"px")),this.update(!0),this.trigger(!0)},i.prototype.toggle=function(t=!1){this.$element.prop("checked")?this.off(t):this.on(t)},i.prototype.on=function(t=!1){if(this.$element.prop("disabled"))return!1;this.$toggle.removeClass(this._offstyle+" off").addClass(this._onstyle),this.$element.prop("checked",!0),t||this.trigger()},i.prototype.off=function(t=!1){if(this.$element.prop("disabled"))return!1;this.$toggle.removeClass(this._onstyle).addClass(this._offstyle+" off"),this.$element.prop("checked",!1),t||this.trigger()},i.prototype.enable=function(){this.$toggle.removeClass("disabled"),this.$toggle.removeAttr("disabled"),this.$element.prop("disabled",!1)},i.prototype.disable=function(){this.$toggle.addClass("disabled"),this.$toggle.attr("disabled","disabled"),this.$element.prop("disabled",!0)},i.prototype.update=function(t){this.$element.prop("disabled")?this.disable():this.enable(),this.$element.prop("checked")?this.on(t):this.off(t)},i.prototype.trigger=function(t){this.$element.off("change.bs.toggle"),t||this.$element.change(),this.$element.on("change.bs.toggle",n.proxy(function(){this.update()},this))},i.prototype.destroy=function(){this.$element.off("change.bs.toggle"),this.$toggleGroup.remove(),this.$element.removeData("bs.toggle"),this.$element.unwrap()};var t=n.fn.bootstrapToggle;n.fn.bootstrapToggle=function(s){var o=Array.prototype.slice.call(arguments,1)[0];return this.each(function(){var t=n(this),e=t.data("bs.toggle");e||t.data("bs.toggle",e=new i(this,"object"==typeof s&&s)),"string"==typeof s&&e[s]&&"boolean"==typeof o?e[s](o):"string"==typeof s&&e[s]&&e[s]()})},n.fn.bootstrapToggle.Constructor=i,n.fn.toggle.noConflict=function(){return n.fn.bootstrapToggle=t,this},n(function(){n("input[type=checkbox][data-toggle^=toggle]").bootstrapToggle()}),n(document).on("click.bs.toggle","div[data-toggle^=toggle]",function(t){n(this).find("input[type=checkbox]").bootstrapToggle("toggle"),t.preventDefault()})}(jQuery);
|
|
13
12
|
//# sourceMappingURL=bootstrap5-toggle.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap5-toggle.min.js","sources":["bootstrap5-toggle.js"],"names":["$","Toggle","element","options","this","$element","extend","defaults","render","
|
|
1
|
+
{"version":3,"file":"bootstrap5-toggle.min.js","sources":["bootstrap5-toggle.js"],"names":["$","Toggle","element","options","this","$element","extend","defaults","render","DEFAULTS","on","off","onstyle","offstyle","size","style","width","height","prototype","attr","_onstyle","_offstyle","$toggleOn","prop","html","addClass","$toggleOff","$toggleHandle","$toggleGroup","append","$toggle","wrap","parent","Math","max","outerWidth","outerHeight","css","update","trigger","toggle","silent","removeClass","enable","removeAttr","disable","change","proxy","destroy","remove","removeData","unwrap","old","fn","bootstrapToggle","option","optArg","Array","slice","call","arguments","each","$this","data","Constructor","noConflict","document","e","find","preventDefault","jQuery"],"mappings":"CAWC,SAAUA,gBAMG,SAATC,EAAmBC,EAASC,GAC/BC,KAAKC,SAAYL,EAAEE,GACnBE,KAAKD,QAAYH,EAAEM,OAAO,GAAIF,KAAKG,WAAYJ,GAC/CC,KAAKI,SAGNP,EAAOQ,SAAW,CACjBC,GAAI,KACJC,IAAK,MACLC,QAAS,UACTC,SAAU,YACVC,KAAM,SACNC,MAAO,GACPC,MAAO,KACPC,OAAQ,MAGThB,EAAOiB,UAAUX,SAAW,WAC3B,MAAO,CACNG,GAAIN,KAAKC,SAASc,KAAK,YAAclB,EAAOQ,SAASC,GACrDC,IAAKP,KAAKC,SAASc,KAAK,aAAelB,EAAOQ,SAASE,IACvDC,QAASR,KAAKC,SAASc,KAAK,iBAAmBlB,EAAOQ,SAASG,QAC/DC,SAAUT,KAAKC,SAASc,KAAK,kBAAoBlB,EAAOQ,SAASI,SACjEC,KAAMV,KAAKC,SAASc,KAAK,cAAgBlB,EAAOQ,SAASK,KACzDC,MAAOX,KAAKC,SAASc,KAAK,eAAiBlB,EAAOQ,SAASM,MAC3DC,MAAOZ,KAAKC,SAASc,KAAK,eAAiBlB,EAAOQ,SAASO,MAC3DC,OAAQb,KAAKC,SAASc,KAAK,gBAAkBlB,EAAOQ,SAASQ,SAI/DhB,EAAOiB,UAAUV,OAAS,WAGzB,IAAIM,EACJ,OAHAV,KAAKgB,SAAW,OAAShB,KAAKD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ACHlC,QAGJH,EAAOiB,UAAU8B,QAAU,WAC1B5C,KAAKC,SAASM,IAAI,oBAClBP,KAAKwB,aAAaqB,SAClB7C,KAAKC,SAAS6C,WAAW,aACzB9C,KAAKC,SAAS8C,UAqBf,IAAIC,EAAMpD,EAAEqD,GAAGC,gBAEftD,EAAEqD,GAAGC,gBAjBL,SAAgBC,GACf,IAAIC,EAASC,MAAMvC,UAAUwC,MAAMC,KAAMC,UAAW,GAAI,GAExD,OAAOxD,KAAKyD,KAAK,WAChB,IAAIC,EAAU9D,EAAEI,MACZ2D,EAAUD,EAAMC,KAAK,aAGpBA,GAAMD,EAAMC,KAAK,YAAcA,EAAO,IAAI9D,EAAOG,KAFvB,iBAAVmD,GAAsBA,IAGrB,iBAAXA,GAAuBQ,EAAKR,IAA6B,kBAAXC,EAAsBO,EAAKR,GAAQC,GACjE,iBAAXD,GAAuBQ,EAAKR,IAASQ,EAAKR,QAQ5DvD,EAAEqD,GAAGC,gBAAgBU,YAAc/D,EAKnCD,EAAEqD,GAAGb,OAAOyB,WAAa,WAExB,OADAjE,EAAEqD,GAAGC,gBAAkBF,EAChBhD,MAMRJ,EAAE,WACDA,EAAE,6CAA6CsD,oBAGhDtD,EAAEkE,UAAUxD,GAAG,kBAAmB,2BAA4B,SAASyD,GACtDnE,EAAEI,MAAMgE,KAAK,wBACnBd,gBAAgB,UAC1Ba,EAAEE,mBAzLH,CA2LCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bootstrap5-toggle",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Pablo Alcaraz Martínez",
|
|
6
6
|
"url": "https://github.com/palcarazm/"
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
"js/*"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "grunt"
|
|
17
|
+
"build": "grunt",
|
|
18
|
+
"postversion": "grunt",
|
|
19
|
+
"prepublishOnly": "grunt"
|
|
18
20
|
},
|
|
19
21
|
"keywords": [
|
|
20
22
|
"bootstrap",
|
|
@@ -37,10 +39,16 @@
|
|
|
37
39
|
"url": "https://github.com/palcarazm/bootstrap5-toggle/issues"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
42
|
+
"cypress": "^10.3.0",
|
|
40
43
|
"doctoc": "^2.2.0",
|
|
41
44
|
"grunt": "^1.5.3",
|
|
45
|
+
"grunt-banner": "^0.6.0",
|
|
42
46
|
"grunt-contrib-clean": "^2.0.1",
|
|
43
47
|
"grunt-contrib-cssmin": "^4.0.0",
|
|
44
48
|
"grunt-contrib-uglify": "^5.2.1"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"bootstrap": "^5.1.3",
|
|
52
|
+
"jquery": "^3.6.0"
|
|
45
53
|
}
|
|
46
54
|
}
|