bootstrap5-toggle 5.3.0-rc1 → 5.3.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/README.md +6 -6
- package/css/bootstrap5-toggle.css +1 -1
- package/css/bootstrap5-toggle.min.css +1 -1
- package/js/bootstrap5-toggle.ecmas.js +26 -21
- package/js/bootstrap5-toggle.ecmas.js.map +1 -1
- package/js/bootstrap5-toggle.ecmas.min.js +2 -2
- package/js/bootstrap5-toggle.ecmas.min.js.map +1 -1
- package/js/bootstrap5-toggle.jquery.js +26 -21
- package/js/bootstrap5-toggle.jquery.js.map +1 -1
- package/js/bootstrap5-toggle.jquery.min.js +2 -2
- package/js/bootstrap5-toggle.jquery.min.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -73,18 +73,18 @@ See EOL for each version in [Security Policy Page](https://github.com/palcarazm/
|
|
|
73
73
|
|
|
74
74
|
```html
|
|
75
75
|
<link
|
|
76
|
-
href="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.3.0
|
|
76
|
+
href="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.3.0/css/bootstrap5-toggle.min.css"
|
|
77
77
|
rel="stylesheet" />
|
|
78
|
-
<script src="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.3.0
|
|
78
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.3.0/js/bootstrap5-toggle.ecmas.min.js"></script>
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
### jQuery Interface
|
|
82
82
|
|
|
83
83
|
```html
|
|
84
84
|
<link
|
|
85
|
-
href="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.3.0
|
|
85
|
+
href="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.3.0/css/bootstrap5-toggle.min.css"
|
|
86
86
|
rel="stylesheet" />
|
|
87
|
-
<script src="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.3.0
|
|
87
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.3.0/js/bootstrap5-toggle.jquery.min.js"></script>
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
## Download
|
|
@@ -96,13 +96,13 @@ See EOL for each version in [Security Policy Page](https://github.com/palcarazm/
|
|
|
96
96
|
[](https://www.npmjs.com/package/bootstrap5-toggle)
|
|
97
97
|
|
|
98
98
|
```ksh
|
|
99
|
-
npm install bootstrap5-toggle@5.3.0
|
|
99
|
+
npm install bootstrap5-toggle@5.3.0
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
## Yarn
|
|
103
103
|
|
|
104
104
|
```ksh
|
|
105
|
-
yarn add bootstrap5-toggle@5.3.0
|
|
105
|
+
yarn add bootstrap5-toggle@5.3.0
|
|
106
106
|
```
|
|
107
107
|
|
|
108
108
|
# Usage
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* Copyright Notice
|
|
2
|
-
* bootstrap5-toggle v5.3.0
|
|
2
|
+
* bootstrap5-toggle v5.3.0
|
|
3
3
|
* https://palcarazm.github.io/bootstrap5-toggle/
|
|
4
4
|
* @author 2011-2014 Min Hur (https://github.com/minhur)
|
|
5
5
|
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
(function (ToggleStateValue) {
|
|
20
20
|
ToggleStateValue["ON"] = "on";
|
|
21
21
|
ToggleStateValue["OFF"] = "off";
|
|
22
|
-
ToggleStateValue["
|
|
22
|
+
ToggleStateValue["MIXED"] = "mixed";
|
|
23
23
|
})(ToggleStateValue || (ToggleStateValue = {}));
|
|
24
24
|
var ToggleStateStatus;
|
|
25
25
|
(function (ToggleStateStatus) {
|
|
@@ -354,7 +354,7 @@
|
|
|
354
354
|
case ToggleStateValue.OFF:
|
|
355
355
|
this.toggle.classList.add(this.offStyle, "off");
|
|
356
356
|
break;
|
|
357
|
-
case ToggleStateValue.
|
|
357
|
+
case ToggleStateValue.MIXED:
|
|
358
358
|
this.toggle.classList.add("indeterminate");
|
|
359
359
|
if (state.checked) {
|
|
360
360
|
this.toggle.classList.add(this.onStyle);
|
|
@@ -487,7 +487,7 @@
|
|
|
487
487
|
case ToggleStateValue.OFF:
|
|
488
488
|
this.tooltip.setContent({ ".tooltip-inner": this.tooltipLabels.off });
|
|
489
489
|
return;
|
|
490
|
-
case ToggleStateValue.
|
|
490
|
+
case ToggleStateValue.MIXED:
|
|
491
491
|
if (this.tooltipLabels.mixed)
|
|
492
492
|
this.tooltip.setContent({ ".tooltip-inner": this.tooltipLabels.mixed });
|
|
493
493
|
return;
|
|
@@ -935,7 +935,7 @@
|
|
|
935
935
|
var indeterminate = this.isTristate && element.indeterminate;
|
|
936
936
|
var value;
|
|
937
937
|
if (indeterminate) {
|
|
938
|
-
value = ToggleStateValue.
|
|
938
|
+
value = ToggleStateValue.MIXED;
|
|
939
939
|
}
|
|
940
940
|
else if (checked) {
|
|
941
941
|
value = ToggleStateValue.ON;
|
|
@@ -1009,9 +1009,9 @@
|
|
|
1009
1009
|
return this.do(ToggleActionType.ON);
|
|
1010
1010
|
return false;
|
|
1011
1011
|
case ToggleActionType.INDETERMINATE:
|
|
1012
|
-
return this.setValueIfChanged(ToggleStateValue.
|
|
1012
|
+
return this.setValueIfChanged(ToggleStateValue.MIXED, undefined, true);
|
|
1013
1013
|
case ToggleActionType.DETERMINATE:
|
|
1014
|
-
if (this.state.value != ToggleStateValue.
|
|
1014
|
+
if (this.state.value != ToggleStateValue.MIXED)
|
|
1015
1015
|
return false;
|
|
1016
1016
|
return this.setValue(this.state.checked ? ToggleStateValue.ON : ToggleStateValue.OFF, this.state.checked, false);
|
|
1017
1017
|
case ToggleActionType.NEXT:
|
|
@@ -1078,7 +1078,7 @@
|
|
|
1078
1078
|
if (this.state.value === ToggleStateValue.ON || this.state.value === ToggleStateValue.OFF) {
|
|
1079
1079
|
return this.do(ToggleActionType.INDETERMINATE);
|
|
1080
1080
|
}
|
|
1081
|
-
if (this.state.value === ToggleStateValue.
|
|
1081
|
+
if (this.state.value === ToggleStateValue.MIXED) {
|
|
1082
1082
|
return this.state.checked
|
|
1083
1083
|
? this.do(ToggleActionType.OFF)
|
|
1084
1084
|
: this.do(ToggleActionType.ON);
|
|
@@ -1204,6 +1204,7 @@
|
|
|
1204
1204
|
};
|
|
1205
1205
|
this.handlerKeyboardEvent = function (e) {
|
|
1206
1206
|
if (e.key === " " || e.key === "Enter") {
|
|
1207
|
+
e.preventDefault();
|
|
1207
1208
|
_this.apply(ToggleActionType.NEXT);
|
|
1208
1209
|
}
|
|
1209
1210
|
};
|
|
@@ -1344,11 +1345,9 @@
|
|
|
1344
1345
|
* Binds a keydown event listener to the root element of the toggle.
|
|
1345
1346
|
* The event listener is responsible for handling keydown events
|
|
1346
1347
|
* and triggering the toggle's state change when a keydown event occurs.
|
|
1347
|
-
* The event listener is bound with the passive option, which means that it will not block
|
|
1348
|
-
* other event listeners from being triggered.
|
|
1349
1348
|
*/
|
|
1350
1349
|
Toggle.prototype.bindKeyboardEventListener = function () {
|
|
1351
|
-
this.domBuilder.root.addEventListener("keydown", this.handlerKeyboardEvent, { passive:
|
|
1350
|
+
this.domBuilder.root.addEventListener("keydown", this.handlerKeyboardEvent, { passive: false });
|
|
1352
1351
|
};
|
|
1353
1352
|
/**
|
|
1354
1353
|
* Unbinds the keydown event listener from the root element of the toggle.
|
|
@@ -1470,27 +1469,33 @@
|
|
|
1470
1469
|
* Enables the toggle.
|
|
1471
1470
|
* If the toggle is currently disabled, this method will set the toggle state to enabled.
|
|
1472
1471
|
* If the silent parameter is false, this method will also trigger the change event.
|
|
1472
|
+
* @param {boolean} silent A boolean indicating whether to trigger the change event after applying the action.
|
|
1473
1473
|
* @returns void
|
|
1474
1474
|
*/
|
|
1475
|
-
Toggle.prototype.enable = function () {
|
|
1476
|
-
|
|
1475
|
+
Toggle.prototype.enable = function (silent) {
|
|
1476
|
+
if (silent === void 0) { silent = false; }
|
|
1477
|
+
this.apply(ToggleActionType.ENABLE, silent);
|
|
1477
1478
|
};
|
|
1478
1479
|
/**
|
|
1479
1480
|
* Disables the toggle.
|
|
1480
1481
|
* If the toggle is currently enabled, this method will set the toggle state to disabled.
|
|
1481
1482
|
* If the silent parameter is false, this method will also trigger the change event.
|
|
1483
|
+
* @param {boolean} silent A boolean indicating whether to trigger the change event after applying the action.
|
|
1482
1484
|
*/
|
|
1483
|
-
Toggle.prototype.disable = function () {
|
|
1484
|
-
|
|
1485
|
+
Toggle.prototype.disable = function (silent) {
|
|
1486
|
+
if (silent === void 0) { silent = false; }
|
|
1487
|
+
this.apply(ToggleActionType.DISABLE, silent);
|
|
1485
1488
|
};
|
|
1486
1489
|
/**
|
|
1487
1490
|
* Sets the toggle state to readonly.
|
|
1488
1491
|
* If the toggle is currently disabled or enabled, this method will set the toggle state to readonly.
|
|
1489
1492
|
* If the silent parameter is false, this method will also trigger the change event.
|
|
1493
|
+
* @param {boolean} silent A boolean indicating whether to trigger the change event after applying the action.
|
|
1490
1494
|
* @returns void
|
|
1491
1495
|
*/
|
|
1492
|
-
Toggle.prototype.readonly = function () {
|
|
1493
|
-
|
|
1496
|
+
Toggle.prototype.readonly = function (silent) {
|
|
1497
|
+
if (silent === void 0) { silent = false; }
|
|
1498
|
+
this.apply(ToggleActionType.READONLY, silent);
|
|
1494
1499
|
};
|
|
1495
1500
|
/**
|
|
1496
1501
|
* Synchronizes the toggle state with the input element and renders the toggle.
|
|
@@ -1559,7 +1564,7 @@
|
|
|
1559
1564
|
return ToggleEvents$1.ON;
|
|
1560
1565
|
case ToggleStateValue.OFF:
|
|
1561
1566
|
return ToggleEvents$1.OFF;
|
|
1562
|
-
case ToggleStateValue.
|
|
1567
|
+
case ToggleStateValue.MIXED:
|
|
1563
1568
|
return ToggleEvents$1.MIXED;
|
|
1564
1569
|
}
|
|
1565
1570
|
};
|
|
@@ -1636,13 +1641,13 @@
|
|
|
1636
1641
|
return _bsToggle.determinate(silent);
|
|
1637
1642
|
case ToggleMethods.ENABLE:
|
|
1638
1643
|
case ToggleMethods.enable:
|
|
1639
|
-
return _bsToggle.enable();
|
|
1644
|
+
return _bsToggle.enable(silent);
|
|
1640
1645
|
case ToggleMethods.DISABLE:
|
|
1641
1646
|
case ToggleMethods.disable:
|
|
1642
|
-
return _bsToggle.disable();
|
|
1647
|
+
return _bsToggle.disable(silent);
|
|
1643
1648
|
case ToggleMethods.READONLY:
|
|
1644
1649
|
case ToggleMethods.readonly:
|
|
1645
|
-
return _bsToggle.readonly();
|
|
1650
|
+
return _bsToggle.readonly(silent);
|
|
1646
1651
|
case ToggleMethods.DESTROY:
|
|
1647
1652
|
case ToggleMethods.destroy:
|
|
1648
1653
|
return _bsToggle.destroy();
|