bootstrap 4.3.1 → 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.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +55 -0
  3. data/CHANGELOG.md +2 -14
  4. data/README.md +28 -5
  5. data/assets/javascripts/bootstrap/alert.js +54 -163
  6. data/assets/javascripts/bootstrap/base-component.js +83 -0
  7. data/assets/javascripts/bootstrap/button.js +44 -152
  8. data/assets/javascripts/bootstrap/carousel.js +289 -569
  9. data/assets/javascripts/bootstrap/collapse.js +170 -349
  10. data/assets/javascripts/bootstrap/dom/data.js +62 -0
  11. data/assets/javascripts/bootstrap/dom/event-handler.js +236 -0
  12. data/assets/javascripts/bootstrap/dom/manipulator.js +71 -0
  13. data/assets/javascripts/bootstrap/dom/selector-engine.js +103 -0
  14. data/assets/javascripts/bootstrap/dropdown.js +303 -496
  15. data/assets/javascripts/bootstrap/modal.js +229 -559
  16. data/assets/javascripts/bootstrap/offcanvas.js +245 -0
  17. data/assets/javascripts/bootstrap/popover.js +61 -226
  18. data/assets/javascripts/bootstrap/scrollspy.js +217 -317
  19. data/assets/javascripts/bootstrap/tab.js +220 -212
  20. data/assets/javascripts/bootstrap/toast.js +145 -229
  21. data/assets/javascripts/bootstrap/tooltip.js +421 -782
  22. data/assets/javascripts/bootstrap/util/backdrop.js +139 -0
  23. data/assets/javascripts/bootstrap/util/component-functions.js +41 -0
  24. data/assets/javascripts/bootstrap/util/config.js +67 -0
  25. data/assets/javascripts/bootstrap/util/focustrap.js +113 -0
  26. data/assets/javascripts/bootstrap/util/index.js +281 -0
  27. data/assets/javascripts/bootstrap/util/sanitizer.js +110 -0
  28. data/assets/javascripts/bootstrap/util/scrollbar.js +112 -0
  29. data/assets/javascripts/bootstrap/util/swipe.js +134 -0
  30. data/assets/javascripts/bootstrap/util/template-factory.js +150 -0
  31. data/assets/javascripts/bootstrap-global-this-define.js +6 -0
  32. data/assets/javascripts/bootstrap-global-this-undefine.js +2 -0
  33. data/assets/javascripts/bootstrap-sprockets.js +23 -7
  34. data/assets/javascripts/bootstrap.js +3690 -3639
  35. data/assets/javascripts/bootstrap.min.js +4 -4
  36. data/assets/stylesheets/_bootstrap-grid.scss +53 -20
  37. data/assets/stylesheets/_bootstrap-reboot.scss +5 -7
  38. data/assets/stylesheets/_bootstrap.scss +21 -13
  39. data/assets/stylesheets/bootstrap/_accordion.scss +158 -0
  40. data/assets/stylesheets/bootstrap/_alert.scss +32 -15
  41. data/assets/stylesheets/bootstrap/_badge.scss +15 -31
  42. data/assets/stylesheets/bootstrap/_breadcrumb.scss +23 -24
  43. data/assets/stylesheets/bootstrap/_button-group.scss +27 -48
  44. data/assets/stylesheets/bootstrap/_buttons.scss +139 -69
  45. data/assets/stylesheets/bootstrap/_card.scss +91 -141
  46. data/assets/stylesheets/bootstrap/_carousel.scss +86 -39
  47. data/assets/stylesheets/bootstrap/_close.scss +51 -29
  48. data/assets/stylesheets/bootstrap/_containers.scss +41 -0
  49. data/assets/stylesheets/bootstrap/_dropdown.scss +131 -72
  50. data/assets/stylesheets/bootstrap/_forms.scss +9 -330
  51. data/assets/stylesheets/bootstrap/_functions.scss +244 -28
  52. data/assets/stylesheets/bootstrap/_grid.scss +18 -31
  53. data/assets/stylesheets/bootstrap/_helpers.scss +12 -0
  54. data/assets/stylesheets/bootstrap/_images.scss +3 -3
  55. data/assets/stylesheets/bootstrap/_list-group.scss +101 -53
  56. data/assets/stylesheets/bootstrap/_maps.scss +174 -0
  57. data/assets/stylesheets/bootstrap/_mixins.scss +13 -18
  58. data/assets/stylesheets/bootstrap/_modal.scss +120 -112
  59. data/assets/stylesheets/bootstrap/_nav.scss +113 -24
  60. data/assets/stylesheets/bootstrap/_navbar.scss +145 -150
  61. data/assets/stylesheets/bootstrap/_offcanvas.scss +146 -0
  62. data/assets/stylesheets/bootstrap/_pagination.scss +74 -38
  63. data/assets/stylesheets/bootstrap/_placeholders.scss +51 -0
  64. data/assets/stylesheets/bootstrap/_popover.scss +99 -74
  65. data/assets/stylesheets/bootstrap/_progress.scss +40 -15
  66. data/assets/stylesheets/bootstrap/_reboot.scss +342 -215
  67. data/assets/stylesheets/bootstrap/_root.scss +174 -9
  68. data/assets/stylesheets/bootstrap/_spinners.scss +52 -22
  69. data/assets/stylesheets/bootstrap/_tables.scss +101 -115
  70. data/assets/stylesheets/bootstrap/_toasts.scss +54 -25
  71. data/assets/stylesheets/bootstrap/_tooltip.scss +67 -63
  72. data/assets/stylesheets/bootstrap/_transitions.scss +8 -1
  73. data/assets/stylesheets/bootstrap/_type.scss +42 -61
  74. data/assets/stylesheets/bootstrap/_utilities.scss +806 -17
  75. data/assets/stylesheets/bootstrap/_variables-dark.scss +85 -0
  76. data/assets/stylesheets/bootstrap/_variables.scss +1235 -615
  77. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +19 -0
  78. data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +94 -0
  79. data/assets/stylesheets/bootstrap/forms/_form-check.scss +188 -0
  80. data/assets/stylesheets/bootstrap/forms/_form-control.scss +214 -0
  81. data/assets/stylesheets/bootstrap/forms/_form-range.scss +91 -0
  82. data/assets/stylesheets/bootstrap/forms/_form-select.scss +80 -0
  83. data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
  84. data/assets/stylesheets/bootstrap/forms/_input-group.scss +132 -0
  85. data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
  86. data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
  87. data/assets/stylesheets/bootstrap/helpers/_color-bg.scss +8 -0
  88. data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +30 -0
  89. data/assets/stylesheets/bootstrap/helpers/_focus-ring.scss +5 -0
  90. data/assets/stylesheets/bootstrap/helpers/_icon-link.scss +25 -0
  91. data/assets/stylesheets/bootstrap/helpers/_position.scss +36 -0
  92. data/assets/stylesheets/bootstrap/helpers/_ratio.scss +26 -0
  93. data/assets/stylesheets/bootstrap/helpers/_stacks.scss +15 -0
  94. data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
  95. data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
  96. data/assets/stylesheets/bootstrap/helpers/_visually-hidden.scss +8 -0
  97. data/assets/stylesheets/bootstrap/helpers/_vr.scss +8 -0
  98. data/assets/stylesheets/bootstrap/mixins/_alert.scss +11 -6
  99. data/assets/stylesheets/bootstrap/mixins/_backdrop.scss +14 -0
  100. data/assets/stylesheets/bootstrap/mixins/_banner.scss +7 -0
  101. data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +37 -22
  102. data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +7 -9
  103. data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +20 -16
  104. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +60 -97
  105. data/assets/stylesheets/bootstrap/mixins/_caret.scss +34 -27
  106. data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
  107. data/assets/stylesheets/bootstrap/mixins/_color-mode.scss +21 -0
  108. data/assets/stylesheets/bootstrap/mixins/_color-scheme.scss +7 -0
  109. data/assets/stylesheets/bootstrap/mixins/_container.scss +11 -0
  110. data/assets/stylesheets/bootstrap/mixins/_forms.scss +77 -116
  111. data/assets/stylesheets/bootstrap/mixins/_gradients.scss +13 -11
  112. data/assets/stylesheets/bootstrap/mixins/_grid.scss +133 -33
  113. data/assets/stylesheets/bootstrap/mixins/_image.scss +0 -20
  114. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +7 -2
  115. data/assets/stylesheets/bootstrap/mixins/_pagination.scss +7 -19
  116. data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +2 -2
  117. data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +24 -0
  118. data/assets/stylesheets/bootstrap/mixins/_transition.scss +18 -8
  119. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +97 -0
  120. data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +33 -0
  121. data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
  122. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +276 -132
  123. data/bootstrap.gemspec +4 -6
  124. data/lib/bootstrap/version.rb +2 -2
  125. data/tasks/updater/js.rb +31 -7
  126. data/tasks/updater/network.rb +10 -4
  127. data/tasks/updater/scss.rb +1 -1
  128. data/tasks/updater.rb +2 -2
  129. data/test/dummy_rails/app/assets/config/manifest.js +3 -0
  130. data/test/dummy_rails/app/assets/javascripts/application.js +4 -3
  131. data/test/dummy_rails/app/assets/stylesheets/.browserslistrc +1 -0
  132. data/test/dummy_rails/app/views/layouts/application.html.erb +3 -1
  133. data/test/dummy_rails/app/views/pages/root.html +89 -0
  134. data/test/dummy_rails/config/application.rb +0 -3
  135. data/test/gemfiles/rails_5_2.gemfile +8 -0
  136. data/test/gemfiles/rails_6_0.gemfile +7 -0
  137. data/test/gemfiles/rails_6_1.gemfile +7 -0
  138. data/test/gemfiles/rails_7_0.gemfile +7 -0
  139. data/test/support/dummy_rails_integration.rb +3 -1
  140. data/test/test_helper.rb +18 -12
  141. metadata +86 -84
  142. data/.travis.yml +0 -17
  143. data/assets/javascripts/bootstrap/util.js +0 -171
  144. data/assets/stylesheets/bootstrap/_code.scss +0 -48
  145. data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -507
  146. data/assets/stylesheets/bootstrap/_input-group.scss +0 -193
  147. data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
  148. data/assets/stylesheets/bootstrap/_media.scss +0 -8
  149. data/assets/stylesheets/bootstrap/_print.scss +0 -141
  150. data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -21
  151. data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -17
  152. data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -14
  153. data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -66
  154. data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
  155. data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -10
  156. data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +0 -33
  157. data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -7
  158. data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -39
  159. data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -16
  160. data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -11
  161. data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -8
  162. data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
  163. data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
  164. data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -75
  165. data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -26
  166. data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -39
  167. data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
  168. data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -11
  169. data/assets/stylesheets/bootstrap/utilities/_overflow.scss +0 -5
  170. data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -32
  171. data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
  172. data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
  173. data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -20
  174. data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -73
  175. data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +0 -19
  176. data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -72
  177. data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -13
  178. data/test/dummy_rails/app/views/pages/root.html.slim +0 -58
  179. /data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
@@ -1,666 +1,386 @@
1
1
  /*!
2
- * Bootstrap carousel.js v4.3.1 (https://getbootstrap.com/)
3
- * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
2
+ * Bootstrap carousel.js v5.3.0 (https://getbootstrap.com/)
3
+ * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
5
  */
6
6
  (function (global, factory) {
7
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
8
- typeof define === 'function' && define.amd ? define(['jquery', './util.js'], factory) :
9
- (global = global || self, global.Carousel = factory(global.jQuery, global.Util));
10
- }(this, function ($, Util) { 'use strict';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./base-component.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./util/index.js'), require('./util/swipe.js')) :
8
+ typeof define === 'function' && define.amd ? define(['./base-component', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './util/index', './util/swipe'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Carousel = factory(global.BaseComponent, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Index, global.Swipe));
10
+ })(this, (function (BaseComponent, EventHandler, Manipulator, SelectorEngine, index_js, Swipe) { 'use strict';
11
11
 
12
- $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
13
- Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
14
-
15
- function _defineProperties(target, props) {
16
- for (var i = 0; i < props.length; i++) {
17
- var descriptor = props[i];
18
- descriptor.enumerable = descriptor.enumerable || false;
19
- descriptor.configurable = true;
20
- if ("value" in descriptor) descriptor.writable = true;
21
- Object.defineProperty(target, descriptor.key, descriptor);
22
- }
23
- }
24
-
25
- function _createClass(Constructor, protoProps, staticProps) {
26
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
27
- if (staticProps) _defineProperties(Constructor, staticProps);
28
- return Constructor;
29
- }
30
-
31
- function _defineProperty(obj, key, value) {
32
- if (key in obj) {
33
- Object.defineProperty(obj, key, {
34
- value: value,
35
- enumerable: true,
36
- configurable: true,
37
- writable: true
38
- });
39
- } else {
40
- obj[key] = value;
41
- }
42
-
43
- return obj;
44
- }
45
-
46
- function _objectSpread(target) {
47
- for (var i = 1; i < arguments.length; i++) {
48
- var source = arguments[i] != null ? arguments[i] : {};
49
- var ownKeys = Object.keys(source);
50
-
51
- if (typeof Object.getOwnPropertySymbols === 'function') {
52
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
53
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
54
- }));
55
- }
56
-
57
- ownKeys.forEach(function (key) {
58
- _defineProperty(target, key, source[key]);
59
- });
60
- }
12
+ /**
13
+ * --------------------------------------------------------------------------
14
+ * Bootstrap carousel.js
15
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
16
+ * --------------------------------------------------------------------------
17
+ */
61
18
 
62
- return target;
63
- }
64
19
 
65
20
  /**
66
- * ------------------------------------------------------------------------
67
21
  * Constants
68
- * ------------------------------------------------------------------------
69
22
  */
70
23
 
71
- var NAME = 'carousel';
72
- var VERSION = '4.3.1';
73
- var DATA_KEY = 'bs.carousel';
74
- var EVENT_KEY = "." + DATA_KEY;
75
- var DATA_API_KEY = '.data-api';
76
- var JQUERY_NO_CONFLICT = $.fn[NAME];
77
- var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
78
-
79
- var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
80
-
81
- var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
82
-
83
- var SWIPE_THRESHOLD = 40;
84
- var Default = {
24
+ const NAME = 'carousel';
25
+ const DATA_KEY = 'bs.carousel';
26
+ const EVENT_KEY = `.${DATA_KEY}`;
27
+ const DATA_API_KEY = '.data-api';
28
+ const ARROW_LEFT_KEY = 'ArrowLeft';
29
+ const ARROW_RIGHT_KEY = 'ArrowRight';
30
+ const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
31
+
32
+ const ORDER_NEXT = 'next';
33
+ const ORDER_PREV = 'prev';
34
+ const DIRECTION_LEFT = 'left';
35
+ const DIRECTION_RIGHT = 'right';
36
+ const EVENT_SLIDE = `slide${EVENT_KEY}`;
37
+ const EVENT_SLID = `slid${EVENT_KEY}`;
38
+ const EVENT_KEYDOWN = `keydown${EVENT_KEY}`;
39
+ const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY}`;
40
+ const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY}`;
41
+ const EVENT_DRAG_START = `dragstart${EVENT_KEY}`;
42
+ const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
43
+ const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
44
+ const CLASS_NAME_CAROUSEL = 'carousel';
45
+ const CLASS_NAME_ACTIVE = 'active';
46
+ const CLASS_NAME_SLIDE = 'slide';
47
+ const CLASS_NAME_END = 'carousel-item-end';
48
+ const CLASS_NAME_START = 'carousel-item-start';
49
+ const CLASS_NAME_NEXT = 'carousel-item-next';
50
+ const CLASS_NAME_PREV = 'carousel-item-prev';
51
+ const SELECTOR_ACTIVE = '.active';
52
+ const SELECTOR_ITEM = '.carousel-item';
53
+ const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
54
+ const SELECTOR_ITEM_IMG = '.carousel-item img';
55
+ const SELECTOR_INDICATORS = '.carousel-indicators';
56
+ const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
57
+ const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
58
+ const KEY_TO_DIRECTION = {
59
+ [ARROW_LEFT_KEY]: DIRECTION_RIGHT,
60
+ [ARROW_RIGHT_KEY]: DIRECTION_LEFT
61
+ };
62
+ const Default = {
85
63
  interval: 5000,
86
64
  keyboard: true,
87
- slide: false,
88
65
  pause: 'hover',
89
- wrap: true,
90
- touch: true
66
+ ride: false,
67
+ touch: true,
68
+ wrap: true
91
69
  };
92
- var DefaultType = {
70
+ const DefaultType = {
93
71
  interval: '(number|boolean)',
72
+ // TODO:v6 remove boolean support
94
73
  keyboard: 'boolean',
95
- slide: '(boolean|string)',
96
74
  pause: '(string|boolean)',
97
- wrap: 'boolean',
98
- touch: 'boolean'
75
+ ride: '(boolean|string)',
76
+ touch: 'boolean',
77
+ wrap: 'boolean'
99
78
  };
100
- var Direction = {
101
- NEXT: 'next',
102
- PREV: 'prev',
103
- LEFT: 'left',
104
- RIGHT: 'right'
105
- };
106
- var Event = {
107
- SLIDE: "slide" + EVENT_KEY,
108
- SLID: "slid" + EVENT_KEY,
109
- KEYDOWN: "keydown" + EVENT_KEY,
110
- MOUSEENTER: "mouseenter" + EVENT_KEY,
111
- MOUSELEAVE: "mouseleave" + EVENT_KEY,
112
- TOUCHSTART: "touchstart" + EVENT_KEY,
113
- TOUCHMOVE: "touchmove" + EVENT_KEY,
114
- TOUCHEND: "touchend" + EVENT_KEY,
115
- POINTERDOWN: "pointerdown" + EVENT_KEY,
116
- POINTERUP: "pointerup" + EVENT_KEY,
117
- DRAG_START: "dragstart" + EVENT_KEY,
118
- LOAD_DATA_API: "load" + EVENT_KEY + DATA_API_KEY,
119
- CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
120
- };
121
- var ClassName = {
122
- CAROUSEL: 'carousel',
123
- ACTIVE: 'active',
124
- SLIDE: 'slide',
125
- RIGHT: 'carousel-item-right',
126
- LEFT: 'carousel-item-left',
127
- NEXT: 'carousel-item-next',
128
- PREV: 'carousel-item-prev',
129
- ITEM: 'carousel-item',
130
- POINTER_EVENT: 'pointer-event'
131
- };
132
- var Selector = {
133
- ACTIVE: '.active',
134
- ACTIVE_ITEM: '.active.carousel-item',
135
- ITEM: '.carousel-item',
136
- ITEM_IMG: '.carousel-item img',
137
- NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
138
- INDICATORS: '.carousel-indicators',
139
- DATA_SLIDE: '[data-slide], [data-slide-to]',
140
- DATA_RIDE: '[data-ride="carousel"]'
141
- };
142
- var PointerType = {
143
- TOUCH: 'touch',
144
- PEN: 'pen'
145
- /**
146
- * ------------------------------------------------------------------------
147
- * Class Definition
148
- * ------------------------------------------------------------------------
149
- */
150
79
 
151
- };
80
+ /**
81
+ * Class definition
82
+ */
152
83
 
153
- var Carousel =
154
- /*#__PURE__*/
155
- function () {
156
- function Carousel(element, config) {
157
- this._items = null;
84
+ class Carousel extends BaseComponent {
85
+ constructor(element, config) {
86
+ super(element, config);
158
87
  this._interval = null;
159
88
  this._activeElement = null;
160
- this._isPaused = false;
161
89
  this._isSliding = false;
162
90
  this.touchTimeout = null;
163
- this.touchStartX = 0;
164
- this.touchDeltaX = 0;
165
- this._config = this._getConfig(config);
166
- this._element = element;
167
- this._indicatorsElement = this._element.querySelector(Selector.INDICATORS);
168
- this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
169
- this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
170
-
91
+ this._swipeHelper = null;
92
+ this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
171
93
  this._addEventListeners();
172
- } // Getters
173
-
94
+ if (this._config.ride === CLASS_NAME_CAROUSEL) {
95
+ this.cycle();
96
+ }
97
+ }
174
98
 
175
- var _proto = Carousel.prototype;
99
+ // Getters
100
+ static get Default() {
101
+ return Default;
102
+ }
103
+ static get DefaultType() {
104
+ return DefaultType;
105
+ }
106
+ static get NAME() {
107
+ return NAME;
108
+ }
176
109
 
177
110
  // Public
178
- _proto.next = function next() {
179
- if (!this._isSliding) {
180
- this._slide(Direction.NEXT);
181
- }
182
- };
183
-
184
- _proto.nextWhenVisible = function nextWhenVisible() {
111
+ next() {
112
+ this._slide(ORDER_NEXT);
113
+ }
114
+ nextWhenVisible() {
115
+ // FIXME TODO use `document.visibilityState`
185
116
  // Don't call next when the page isn't visible
186
117
  // or the carousel or its parent isn't visible
187
- if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
118
+ if (!document.hidden && index_js.isVisible(this._element)) {
188
119
  this.next();
189
120
  }
190
- };
191
-
192
- _proto.prev = function prev() {
193
- if (!this._isSliding) {
194
- this._slide(Direction.PREV);
195
- }
196
- };
197
-
198
- _proto.pause = function pause(event) {
199
- if (!event) {
200
- this._isPaused = true;
201
- }
202
-
203
- if (this._element.querySelector(Selector.NEXT_PREV)) {
204
- Util.triggerTransitionEnd(this._element);
205
- this.cycle(true);
206
- }
207
-
208
- clearInterval(this._interval);
209
- this._interval = null;
210
- };
211
-
212
- _proto.cycle = function cycle(event) {
213
- if (!event) {
214
- this._isPaused = false;
121
+ }
122
+ prev() {
123
+ this._slide(ORDER_PREV);
124
+ }
125
+ pause() {
126
+ if (this._isSliding) {
127
+ index_js.triggerTransitionEnd(this._element);
215
128
  }
216
-
217
- if (this._interval) {
218
- clearInterval(this._interval);
219
- this._interval = null;
129
+ this._clearInterval();
130
+ }
131
+ cycle() {
132
+ this._clearInterval();
133
+ this._updateInterval();
134
+ this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval);
135
+ }
136
+ _maybeEnableCycle() {
137
+ if (!this._config.ride) {
138
+ return;
220
139
  }
221
-
222
- if (this._config.interval && !this._isPaused) {
223
- this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
140
+ if (this._isSliding) {
141
+ EventHandler.one(this._element, EVENT_SLID, () => this.cycle());
142
+ return;
224
143
  }
225
- };
226
-
227
- _proto.to = function to(index) {
228
- var _this = this;
229
-
230
- this._activeElement = this._element.querySelector(Selector.ACTIVE_ITEM);
231
-
232
- var activeIndex = this._getItemIndex(this._activeElement);
233
-
234
- if (index > this._items.length - 1 || index < 0) {
144
+ this.cycle();
145
+ }
146
+ to(index) {
147
+ const items = this._getItems();
148
+ if (index > items.length - 1 || index < 0) {
235
149
  return;
236
150
  }
237
-
238
151
  if (this._isSliding) {
239
- $(this._element).one(Event.SLID, function () {
240
- return _this.to(index);
241
- });
152
+ EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
242
153
  return;
243
154
  }
244
-
155
+ const activeIndex = this._getItemIndex(this._getActive());
245
156
  if (activeIndex === index) {
246
- this.pause();
247
- this.cycle();
248
157
  return;
249
158
  }
250
-
251
- var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
252
-
253
- this._slide(direction, this._items[index]);
254
- };
255
-
256
- _proto.dispose = function dispose() {
257
- $(this._element).off(EVENT_KEY);
258
- $.removeData(this._element, DATA_KEY);
259
- this._items = null;
260
- this._config = null;
261
- this._element = null;
262
- this._interval = null;
263
- this._isPaused = null;
264
- this._isSliding = null;
265
- this._activeElement = null;
266
- this._indicatorsElement = null;
267
- } // Private
268
- ;
269
-
270
- _proto._getConfig = function _getConfig(config) {
271
- config = _objectSpread({}, Default, config);
272
- Util.typeCheckConfig(NAME, config, DefaultType);
273
- return config;
274
- };
275
-
276
- _proto._handleSwipe = function _handleSwipe() {
277
- var absDeltax = Math.abs(this.touchDeltaX);
278
-
279
- if (absDeltax <= SWIPE_THRESHOLD) {
280
- return;
281
- }
282
-
283
- var direction = absDeltax / this.touchDeltaX; // swipe left
284
-
285
- if (direction > 0) {
286
- this.prev();
287
- } // swipe right
288
-
289
-
290
- if (direction < 0) {
291
- this.next();
159
+ const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
160
+ this._slide(order, items[index]);
161
+ }
162
+ dispose() {
163
+ if (this._swipeHelper) {
164
+ this._swipeHelper.dispose();
292
165
  }
293
- };
294
-
295
- _proto._addEventListeners = function _addEventListeners() {
296
- var _this2 = this;
166
+ super.dispose();
167
+ }
297
168
 
169
+ // Private
170
+ _configAfterMerge(config) {
171
+ config.defaultInterval = config.interval;
172
+ return config;
173
+ }
174
+ _addEventListeners() {
298
175
  if (this._config.keyboard) {
299
- $(this._element).on(Event.KEYDOWN, function (event) {
300
- return _this2._keydown(event);
301
- });
176
+ EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
302
177
  }
303
-
304
178
  if (this._config.pause === 'hover') {
305
- $(this._element).on(Event.MOUSEENTER, function (event) {
306
- return _this2.pause(event);
307
- }).on(Event.MOUSELEAVE, function (event) {
308
- return _this2.cycle(event);
309
- });
179
+ EventHandler.on(this._element, EVENT_MOUSEENTER, () => this.pause());
180
+ EventHandler.on(this._element, EVENT_MOUSELEAVE, () => this._maybeEnableCycle());
310
181
  }
311
-
312
- if (this._config.touch) {
182
+ if (this._config.touch && Swipe.isSupported()) {
313
183
  this._addTouchEventListeners();
314
184
  }
315
- };
316
-
317
- _proto._addTouchEventListeners = function _addTouchEventListeners() {
318
- var _this3 = this;
319
-
320
- if (!this._touchSupported) {
321
- return;
185
+ }
186
+ _addTouchEventListeners() {
187
+ for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) {
188
+ EventHandler.on(img, EVENT_DRAG_START, event => event.preventDefault());
322
189
  }
323
-
324
- var start = function start(event) {
325
- if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
326
- _this3.touchStartX = event.originalEvent.clientX;
327
- } else if (!_this3._pointerEvent) {
328
- _this3.touchStartX = event.originalEvent.touches[0].clientX;
190
+ const endCallBack = () => {
191
+ if (this._config.pause !== 'hover') {
192
+ return;
329
193
  }
330
- };
331
-
332
- var move = function move(event) {
333
- // ensure swiping with one touch and not pinching
334
- if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
335
- _this3.touchDeltaX = 0;
336
- } else {
337
- _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
338
- }
339
- };
340
-
341
- var end = function end(event) {
342
- if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
343
- _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
344
- }
345
-
346
- _this3._handleSwipe();
347
194
 
348
- if (_this3._config.pause === 'hover') {
349
- // If it's a touch-enabled device, mouseenter/leave are fired as
350
- // part of the mouse compatibility events on first tap - the carousel
351
- // would stop cycling until user tapped out of it;
352
- // here, we listen for touchend, explicitly pause the carousel
353
- // (as if it's the second time we tap on it, mouseenter compat event
354
- // is NOT fired) and after a timeout (to allow for mouse compatibility
355
- // events to fire) we explicitly restart cycling
356
- _this3.pause();
195
+ // If it's a touch-enabled device, mouseenter/leave are fired as
196
+ // part of the mouse compatibility events on first tap - the carousel
197
+ // would stop cycling until user tapped out of it;
198
+ // here, we listen for touchend, explicitly pause the carousel
199
+ // (as if it's the second time we tap on it, mouseenter compat event
200
+ // is NOT fired) and after a timeout (to allow for mouse compatibility
201
+ // events to fire) we explicitly restart cycling
357
202
 
358
- if (_this3.touchTimeout) {
359
- clearTimeout(_this3.touchTimeout);
360
- }
361
-
362
- _this3.touchTimeout = setTimeout(function (event) {
363
- return _this3.cycle(event);
364
- }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
203
+ this.pause();
204
+ if (this.touchTimeout) {
205
+ clearTimeout(this.touchTimeout);
365
206
  }
207
+ this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
366
208
  };
367
-
368
- $(this._element.querySelectorAll(Selector.ITEM_IMG)).on(Event.DRAG_START, function (e) {
369
- return e.preventDefault();
370
- });
371
-
372
- if (this._pointerEvent) {
373
- $(this._element).on(Event.POINTERDOWN, function (event) {
374
- return start(event);
375
- });
376
- $(this._element).on(Event.POINTERUP, function (event) {
377
- return end(event);
378
- });
379
-
380
- this._element.classList.add(ClassName.POINTER_EVENT);
381
- } else {
382
- $(this._element).on(Event.TOUCHSTART, function (event) {
383
- return start(event);
384
- });
385
- $(this._element).on(Event.TOUCHMOVE, function (event) {
386
- return move(event);
387
- });
388
- $(this._element).on(Event.TOUCHEND, function (event) {
389
- return end(event);
390
- });
391
- }
392
- };
393
-
394
- _proto._keydown = function _keydown(event) {
209
+ const swipeConfig = {
210
+ leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
211
+ rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
212
+ endCallback: endCallBack
213
+ };
214
+ this._swipeHelper = new Swipe(this._element, swipeConfig);
215
+ }
216
+ _keydown(event) {
395
217
  if (/input|textarea/i.test(event.target.tagName)) {
396
218
  return;
397
219
  }
398
-
399
- switch (event.which) {
400
- case ARROW_LEFT_KEYCODE:
401
- event.preventDefault();
402
- this.prev();
403
- break;
404
-
405
- case ARROW_RIGHT_KEYCODE:
406
- event.preventDefault();
407
- this.next();
408
- break;
409
-
410
- default:
220
+ const direction = KEY_TO_DIRECTION[event.key];
221
+ if (direction) {
222
+ event.preventDefault();
223
+ this._slide(this._directionToOrder(direction));
411
224
  }
412
- };
413
-
414
- _proto._getItemIndex = function _getItemIndex(element) {
415
- this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector.ITEM)) : [];
416
- return this._items.indexOf(element);
417
- };
418
-
419
- _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
420
- var isNextDirection = direction === Direction.NEXT;
421
- var isPrevDirection = direction === Direction.PREV;
422
-
423
- var activeIndex = this._getItemIndex(activeElement);
424
-
425
- var lastItemIndex = this._items.length - 1;
426
- var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
427
-
428
- if (isGoingToWrap && !this._config.wrap) {
429
- return activeElement;
225
+ }
226
+ _getItemIndex(element) {
227
+ return this._getItems().indexOf(element);
228
+ }
229
+ _setActiveIndicatorElement(index) {
230
+ if (!this._indicatorsElement) {
231
+ return;
430
232
  }
431
-
432
- var delta = direction === Direction.PREV ? -1 : 1;
433
- var itemIndex = (activeIndex + delta) % this._items.length;
434
- return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
435
- };
436
-
437
- _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
438
- var targetIndex = this._getItemIndex(relatedTarget);
439
-
440
- var fromIndex = this._getItemIndex(this._element.querySelector(Selector.ACTIVE_ITEM));
441
-
442
- var slideEvent = $.Event(Event.SLIDE, {
443
- relatedTarget: relatedTarget,
444
- direction: eventDirectionName,
445
- from: fromIndex,
446
- to: targetIndex
447
- });
448
- $(this._element).trigger(slideEvent);
449
- return slideEvent;
450
- };
451
-
452
- _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
453
- if (this._indicatorsElement) {
454
- var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector.ACTIVE));
455
- $(indicators).removeClass(ClassName.ACTIVE);
456
-
457
- var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
458
-
459
- if (nextIndicator) {
460
- $(nextIndicator).addClass(ClassName.ACTIVE);
461
- }
233
+ const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
234
+ activeIndicator.classList.remove(CLASS_NAME_ACTIVE);
235
+ activeIndicator.removeAttribute('aria-current');
236
+ const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
237
+ if (newActiveIndicator) {
238
+ newActiveIndicator.classList.add(CLASS_NAME_ACTIVE);
239
+ newActiveIndicator.setAttribute('aria-current', 'true');
462
240
  }
463
- };
464
-
465
- _proto._slide = function _slide(direction, element) {
466
- var _this4 = this;
467
-
468
- var activeElement = this._element.querySelector(Selector.ACTIVE_ITEM);
469
-
470
- var activeElementIndex = this._getItemIndex(activeElement);
471
-
472
- var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
473
-
474
- var nextElementIndex = this._getItemIndex(nextElement);
475
-
476
- var isCycling = Boolean(this._interval);
477
- var directionalClassName;
478
- var orderClassName;
479
- var eventDirectionName;
480
-
481
- if (direction === Direction.NEXT) {
482
- directionalClassName = ClassName.LEFT;
483
- orderClassName = ClassName.NEXT;
484
- eventDirectionName = Direction.LEFT;
485
- } else {
486
- directionalClassName = ClassName.RIGHT;
487
- orderClassName = ClassName.PREV;
488
- eventDirectionName = Direction.RIGHT;
241
+ }
242
+ _updateInterval() {
243
+ const element = this._activeElement || this._getActive();
244
+ if (!element) {
245
+ return;
489
246
  }
490
-
491
- if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) {
492
- this._isSliding = false;
247
+ const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
248
+ this._config.interval = elementInterval || this._config.defaultInterval;
249
+ }
250
+ _slide(order, element = null) {
251
+ if (this._isSliding) {
493
252
  return;
494
253
  }
495
-
496
- var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
497
-
498
- if (slideEvent.isDefaultPrevented()) {
254
+ const activeElement = this._getActive();
255
+ const isNext = order === ORDER_NEXT;
256
+ const nextElement = element || index_js.getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap);
257
+ if (nextElement === activeElement) {
258
+ return;
259
+ }
260
+ const nextElementIndex = this._getItemIndex(nextElement);
261
+ const triggerEvent = eventName => {
262
+ return EventHandler.trigger(this._element, eventName, {
263
+ relatedTarget: nextElement,
264
+ direction: this._orderToDirection(order),
265
+ from: this._getItemIndex(activeElement),
266
+ to: nextElementIndex
267
+ });
268
+ };
269
+ const slideEvent = triggerEvent(EVENT_SLIDE);
270
+ if (slideEvent.defaultPrevented) {
499
271
  return;
500
272
  }
501
-
502
273
  if (!activeElement || !nextElement) {
503
274
  // Some weirdness is happening, so we bail
275
+ // TODO: change tests that use empty divs to avoid this check
504
276
  return;
505
277
  }
506
-
278
+ const isCycling = Boolean(this._interval);
279
+ this.pause();
507
280
  this._isSliding = true;
508
-
509
- if (isCycling) {
510
- this.pause();
511
- }
512
-
513
- this._setActiveIndicatorElement(nextElement);
514
-
515
- var slidEvent = $.Event(Event.SLID, {
516
- relatedTarget: nextElement,
517
- direction: eventDirectionName,
518
- from: activeElementIndex,
519
- to: nextElementIndex
520
- });
521
-
522
- if ($(this._element).hasClass(ClassName.SLIDE)) {
523
- $(nextElement).addClass(orderClassName);
524
- Util.reflow(nextElement);
525
- $(activeElement).addClass(directionalClassName);
526
- $(nextElement).addClass(directionalClassName);
527
- var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
528
-
529
- if (nextElementInterval) {
530
- this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
531
- this._config.interval = nextElementInterval;
532
- } else {
533
- this._config.interval = this._config.defaultInterval || this._config.interval;
534
- }
535
-
536
- var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
537
- $(activeElement).one(Util.TRANSITION_END, function () {
538
- $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName.ACTIVE);
539
- $(activeElement).removeClass(ClassName.ACTIVE + " " + orderClassName + " " + directionalClassName);
540
- _this4._isSliding = false;
541
- setTimeout(function () {
542
- return $(_this4._element).trigger(slidEvent);
543
- }, 0);
544
- }).emulateTransitionEnd(transitionDuration);
545
- } else {
546
- $(activeElement).removeClass(ClassName.ACTIVE);
547
- $(nextElement).addClass(ClassName.ACTIVE);
281
+ this._setActiveIndicatorElement(nextElementIndex);
282
+ this._activeElement = nextElement;
283
+ const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
284
+ const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
285
+ nextElement.classList.add(orderClassName);
286
+ index_js.reflow(nextElement);
287
+ activeElement.classList.add(directionalClassName);
288
+ nextElement.classList.add(directionalClassName);
289
+ const completeCallBack = () => {
290
+ nextElement.classList.remove(directionalClassName, orderClassName);
291
+ nextElement.classList.add(CLASS_NAME_ACTIVE);
292
+ activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName);
548
293
  this._isSliding = false;
549
- $(this._element).trigger(slidEvent);
550
- }
551
-
294
+ triggerEvent(EVENT_SLID);
295
+ };
296
+ this._queueCallback(completeCallBack, activeElement, this._isAnimated());
552
297
  if (isCycling) {
553
298
  this.cycle();
554
299
  }
555
- } // Static
556
- ;
300
+ }
301
+ _isAnimated() {
302
+ return this._element.classList.contains(CLASS_NAME_SLIDE);
303
+ }
304
+ _getActive() {
305
+ return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
306
+ }
307
+ _getItems() {
308
+ return SelectorEngine.find(SELECTOR_ITEM, this._element);
309
+ }
310
+ _clearInterval() {
311
+ if (this._interval) {
312
+ clearInterval(this._interval);
313
+ this._interval = null;
314
+ }
315
+ }
316
+ _directionToOrder(direction) {
317
+ if (index_js.isRTL()) {
318
+ return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
319
+ }
320
+ return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
321
+ }
322
+ _orderToDirection(order) {
323
+ if (index_js.isRTL()) {
324
+ return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
325
+ }
326
+ return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
327
+ }
557
328
 
558
- Carousel._jQueryInterface = function _jQueryInterface(config) {
329
+ // Static
330
+ static jQueryInterface(config) {
559
331
  return this.each(function () {
560
- var data = $(this).data(DATA_KEY);
561
-
562
- var _config = _objectSpread({}, Default, $(this).data());
563
-
564
- if (typeof config === 'object') {
565
- _config = _objectSpread({}, _config, config);
566
- }
567
-
568
- var action = typeof config === 'string' ? config : _config.slide;
569
-
570
- if (!data) {
571
- data = new Carousel(this, _config);
572
- $(this).data(DATA_KEY, data);
573
- }
574
-
332
+ const data = Carousel.getOrCreateInstance(this, config);
575
333
  if (typeof config === 'number') {
576
334
  data.to(config);
577
- } else if (typeof action === 'string') {
578
- if (typeof data[action] === 'undefined') {
579
- throw new TypeError("No method named \"" + action + "\"");
335
+ return;
336
+ }
337
+ if (typeof config === 'string') {
338
+ if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
339
+ throw new TypeError(`No method named "${config}"`);
580
340
  }
581
-
582
- data[action]();
583
- } else if (_config.interval && _config.ride) {
584
- data.pause();
585
- data.cycle();
341
+ data[config]();
586
342
  }
587
343
  });
588
- };
589
-
590
- Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
591
- var selector = Util.getSelectorFromElement(this);
592
-
593
- if (!selector) {
594
- return;
595
- }
596
-
597
- var target = $(selector)[0];
598
-
599
- if (!target || !$(target).hasClass(ClassName.CAROUSEL)) {
600
- return;
601
- }
602
-
603
- var config = _objectSpread({}, $(target).data(), $(this).data());
604
-
605
- var slideIndex = this.getAttribute('data-slide-to');
606
-
607
- if (slideIndex) {
608
- config.interval = false;
609
- }
610
-
611
- Carousel._jQueryInterface.call($(target), config);
612
-
613
- if (slideIndex) {
614
- $(target).data(DATA_KEY).to(slideIndex);
615
- }
616
-
617
- event.preventDefault();
618
- };
619
-
620
- _createClass(Carousel, null, [{
621
- key: "VERSION",
622
- get: function get() {
623
- return VERSION;
624
- }
625
- }, {
626
- key: "Default",
627
- get: function get() {
628
- return Default;
629
- }
630
- }]);
344
+ }
345
+ }
631
346
 
632
- return Carousel;
633
- }();
634
347
  /**
635
- * ------------------------------------------------------------------------
636
- * Data Api implementation
637
- * ------------------------------------------------------------------------
348
+ * Data API implementation
638
349
  */
639
350
 
640
-
641
- $(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler);
642
- $(window).on(Event.LOAD_DATA_API, function () {
643
- var carousels = [].slice.call(document.querySelectorAll(Selector.DATA_RIDE));
644
-
645
- for (var i = 0, len = carousels.length; i < len; i++) {
646
- var $carousel = $(carousels[i]);
647
-
648
- Carousel._jQueryInterface.call($carousel, $carousel.data());
351
+ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, function (event) {
352
+ const target = SelectorEngine.getElementFromSelector(this);
353
+ if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
354
+ return;
355
+ }
356
+ event.preventDefault();
357
+ const carousel = Carousel.getOrCreateInstance(target);
358
+ const slideIndex = this.getAttribute('data-bs-slide-to');
359
+ if (slideIndex) {
360
+ carousel.to(slideIndex);
361
+ carousel._maybeEnableCycle();
362
+ return;
363
+ }
364
+ if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
365
+ carousel.next();
366
+ carousel._maybeEnableCycle();
367
+ return;
368
+ }
369
+ carousel.prev();
370
+ carousel._maybeEnableCycle();
371
+ });
372
+ EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
373
+ const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
374
+ for (const carousel of carousels) {
375
+ Carousel.getOrCreateInstance(carousel);
649
376
  }
650
377
  });
378
+
651
379
  /**
652
- * ------------------------------------------------------------------------
653
380
  * jQuery
654
- * ------------------------------------------------------------------------
655
381
  */
656
382
 
657
- $.fn[NAME] = Carousel._jQueryInterface;
658
- $.fn[NAME].Constructor = Carousel;
659
-
660
- $.fn[NAME].noConflict = function () {
661
- $.fn[NAME] = JQUERY_NO_CONFLICT;
662
- return Carousel._jQueryInterface;
663
- };
383
+ index_js.defineJQueryPlugin(Carousel);
664
384
 
665
385
  return Carousel;
666
386