aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2021-09-10 03:41:31 +0300
committerGeoSot <[email protected]>2021-09-10 13:27:26 +0300
commitaa6cc88ebde097c43df65060f51ff0fe7a0849fb (patch)
treebe872bf285b47dc09e121865400e1e857d2e08a1
parent8ea4d43695a17a822b332097637644e204aa3ab8 (diff)
downloadbootstrap-aa6cc88ebde097c43df65060f51ff0fe7a0849fb.tar.xz
bootstrap-aa6cc88ebde097c43df65060f51ff0fe7a0849fb.zip
move interface to jqueryInterface
-rw-r--r--js/src/carousel.js52
1 files changed, 24 insertions, 28 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js
index 6ed5a7bf8..d92f47721 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -497,40 +497,36 @@ class Carousel extends BaseComponent {
// Static
- static carouselInterface(element, config) {
- const data = Carousel.getOrCreateInstance(element, config)
-
- let { _config } = data
- if (typeof config === 'object') {
- _config = {
- ..._config,
- ...config
- }
- }
+ static jQueryInterface(config) {
+ return this.each(function () {
+ const data = Carousel.getOrCreateInstance(this, config)
- if (typeof config === 'number') {
- data.to(config)
- return
- }
+ let { _config } = data
+ if (typeof config === 'object') {
+ _config = {
+ ..._config,
+ ...config
+ }
+ }
- if (typeof config === 'string') {
- if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
- throw new TypeError(`No method named "${config}"`)
+ if (typeof config === 'number') {
+ data.to(config)
+ return
}
- data[config]()
- return
- }
+ if (typeof config === 'string') {
+ if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
+ throw new TypeError(`No method named "${config}"`)
+ }
- if (_config.interval && _config.ride) {
- data.pause()
- data.cycle()
- }
- }
+ data[config]()
+ return
+ }
- static jQueryInterface(config) {
- return this.each(function () {
- Carousel.carouselInterface(this, config)
+ if (_config.interval && _config.ride) {
+ data.pause()
+ data.cycle()
+ }
})
}
}