From aa6cc88ebde097c43df65060f51ff0fe7a0849fb Mon Sep 17 00:00:00 2001 From: GeoSot Date: Fri, 10 Sep 2021 03:41:31 +0300 Subject: move interface to jqueryInterface --- js/src/carousel.js | 52 ++++++++++++++++++++++++---------------------------- 1 file 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() + } }) } } -- cgit v1.2.3