administrate-bootstrap-theme 0.1.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +72 -31
  3. data/app/assets/javascripts/administrate-bootstrap-theme/bootstrap.bundle.js +6780 -0
  4. data/app/assets/stylesheets/administrate-bootstrap-theme/_base.scss +2 -10
  5. data/app/assets/stylesheets/administrate-bootstrap-theme/_variables.scss +8 -1
  6. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_accordion.scss +4 -2
  7. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_alert.scss +0 -0
  8. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_badge.scss +0 -0
  9. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_breadcrumb.scss +0 -0
  10. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_button-group.scss +0 -0
  11. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_buttons.scss +0 -0
  12. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_card.scss +7 -6
  13. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_carousel.scss +2 -2
  14. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_close.scss +0 -0
  15. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_containers.scss +0 -0
  16. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_dropdown.scss +11 -17
  17. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_forms.scss +0 -0
  18. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_functions.scss +94 -3
  19. data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/_grid.scss +33 -0
  20. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_helpers.scss +2 -0
  21. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_images.scss +1 -1
  22. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_list-group.scss +5 -5
  23. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_mixins.scss +2 -0
  24. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_modal.scss +7 -35
  25. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_nav.scss +0 -0
  26. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_navbar.scss +30 -1
  27. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_offcanvas.scss +19 -13
  28. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_pagination.scss +0 -0
  29. data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/_placeholders.scss +51 -0
  30. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_popover.scss +10 -10
  31. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_progress.scss +0 -0
  32. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_reboot.scss +12 -8
  33. data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/_root.scss +53 -0
  34. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_spinners.scss +2 -2
  35. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_tables.scss +1 -0
  36. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_toasts.scss +3 -3
  37. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_tooltip.scss +4 -4
  38. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_transitions.scss +6 -0
  39. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_type.scss +0 -0
  40. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_utilities.scss +44 -8
  41. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_variables.scss +193 -28
  42. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap-grid.scss +1 -1
  43. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap-reboot.scss +1 -1
  44. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap-utilities.scss +1 -1
  45. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap.scss +2 -1
  46. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_floating-labels.scss +3 -1
  47. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-check.scss +1 -1
  48. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-control.scss +1 -1
  49. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-range.scss +1 -1
  50. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-select.scss +3 -0
  51. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-text.scss +0 -0
  52. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_input-group.scss +0 -0
  53. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_labels.scss +0 -0
  54. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_validation.scss +0 -0
  55. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_clearfix.scss +0 -0
  56. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_colored-links.scss +0 -0
  57. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_position.scss +0 -0
  58. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_ratio.scss +0 -0
  59. data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/helpers/_stacks.scss +15 -0
  60. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_stretched-link.scss +0 -0
  61. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_text-truncation.scss +0 -0
  62. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_visually-hidden.scss +0 -0
  63. data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/helpers/_vr.scss +8 -0
  64. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_alert.scss +0 -0
  65. data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/mixins/_backdrop.scss +14 -0
  66. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_border-radius.scss +0 -0
  67. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_box-shadow.scss +0 -0
  68. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_breakpoints.scss +0 -0
  69. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_buttons.scss +1 -1
  70. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_caret.scss +0 -0
  71. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_clearfix.scss +0 -0
  72. data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/mixins/_color-scheme.scss +7 -0
  73. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_container.scss +0 -0
  74. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_deprecate.scss +0 -0
  75. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_forms.scss +15 -5
  76. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_gradients.scss +0 -0
  77. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_grid.scss +40 -10
  78. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_image.scss +0 -0
  79. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_list-group.scss +0 -0
  80. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_lists.scss +0 -0
  81. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_pagination.scss +0 -0
  82. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_reset-text.scss +0 -0
  83. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_resize.scss +0 -0
  84. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_table-variants.scss +0 -0
  85. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_text-truncate.scss +0 -0
  86. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_transition.scss +0 -0
  87. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_utilities.scss +27 -6
  88. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_visually-hidden.scss +0 -0
  89. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/utilities/_api.scss +0 -0
  90. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/vendor/_rfs.scss +55 -13
  91. data/app/assets/stylesheets/administrate-bootstrap-theme/colors/_autumn.scss +8 -0
  92. data/app/assets/stylesheets/administrate-bootstrap-theme/colors/_default.scss +8 -0
  93. data/app/assets/stylesheets/administrate-bootstrap-theme/colors/_forest.scss +9 -0
  94. data/app/assets/stylesheets/administrate-bootstrap-theme/colors/_industrial.scss +8 -0
  95. data/app/assets/stylesheets/administrate-bootstrap-theme/colors/_water.scss +8 -0
  96. data/app/assets/stylesheets/administrate-bootstrap-theme/components/_content_body.scss +21 -1
  97. data/app/assets/stylesheets/administrate-bootstrap-theme/components/_content_header.scss +1 -1
  98. data/app/assets/stylesheets/administrate-bootstrap-theme/components/_form.scss +2 -0
  99. data/app/assets/stylesheets/administrate-bootstrap-theme/components/_navigation.scss +22 -3
  100. data/app/assets/stylesheets/administrate-bootstrap-theme/components/_pagination.scss +1 -1
  101. data/app/assets/stylesheets/administrate-bootstrap-theme/fonts/_lato.scss +5 -0
  102. data/app/assets/stylesheets/administrate-bootstrap-theme/fonts/_montserrat.scss +5 -0
  103. data/app/assets/stylesheets/administrate-bootstrap-theme/fonts/_open_sans.scss +5 -0
  104. data/app/assets/stylesheets/administrate-bootstrap-theme/fonts/_roboto.scss +5 -0
  105. data/app/assets/stylesheets/administrate-bootstrap-theme/fonts/_source_sans_pro.scss +5 -0
  106. data/app/assets/stylesheets/administrate-bootstrap-theme/theme.scss +10 -51
  107. data/lib/administrate-bootstrap-theme/engine.rb +0 -2
  108. data/lib/administrate-bootstrap-theme/version.rb +2 -1
  109. data/lib/generators/administrate_bootstrap_theme/install/USAGE +10 -0
  110. data/lib/generators/administrate_bootstrap_theme/install/install_generator.rb +33 -0
  111. data/package.json +10 -0
  112. metadata +113 -199
  113. data/Rakefile +0 -16
  114. data/app/assets/javascripts/administrate-bootstrap-theme/theme.js +0 -2
  115. data/node_modules/bootstrap/js/src/alert.js +0 -141
  116. data/node_modules/bootstrap/js/src/base-component.js +0 -46
  117. data/node_modules/bootstrap/js/src/button.js +0 -95
  118. data/node_modules/bootstrap/js/src/carousel.js +0 -624
  119. data/node_modules/bootstrap/js/src/collapse.js +0 -410
  120. data/node_modules/bootstrap/js/src/dom/data.js +0 -57
  121. data/node_modules/bootstrap/js/src/dom/event-handler.js +0 -331
  122. data/node_modules/bootstrap/js/src/dom/manipulator.js +0 -80
  123. data/node_modules/bootstrap/js/src/dom/selector-engine.js +0 -75
  124. data/node_modules/bootstrap/js/src/dropdown.js +0 -543
  125. data/node_modules/bootstrap/js/src/modal.js +0 -582
  126. data/node_modules/bootstrap/js/src/offcanvas.js +0 -279
  127. data/node_modules/bootstrap/js/src/popover.js +0 -171
  128. data/node_modules/bootstrap/js/src/scrollspy.js +0 -319
  129. data/node_modules/bootstrap/js/src/tab.js +0 -220
  130. data/node_modules/bootstrap/js/src/toast.js +0 -219
  131. data/node_modules/bootstrap/js/src/tooltip.js +0 -802
  132. data/node_modules/bootstrap/js/src/util/index.js +0 -253
  133. data/node_modules/bootstrap/js/src/util/sanitizer.js +0 -127
  134. data/node_modules/bootstrap/js/src/util/scrollbar.js +0 -70
  135. data/node_modules/bootstrap/scss/_grid.scss +0 -22
  136. data/node_modules/bootstrap/scss/_root.scss +0 -16
@@ -1,95 +0,0 @@
1
- /**
2
- * --------------------------------------------------------------------------
3
- * Bootstrap (v5.0.0-beta3): button.js
4
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
- * --------------------------------------------------------------------------
6
- */
7
-
8
- import { defineJQueryPlugin } from './util/index'
9
- import Data from './dom/data'
10
- import EventHandler from './dom/event-handler'
11
- import BaseComponent from './base-component'
12
-
13
- /**
14
- * ------------------------------------------------------------------------
15
- * Constants
16
- * ------------------------------------------------------------------------
17
- */
18
-
19
- const NAME = 'button'
20
- const DATA_KEY = 'bs.button'
21
- const EVENT_KEY = `.${DATA_KEY}`
22
- const DATA_API_KEY = '.data-api'
23
-
24
- const CLASS_NAME_ACTIVE = 'active'
25
-
26
- const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="button"]'
27
-
28
- const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
29
-
30
- /**
31
- * ------------------------------------------------------------------------
32
- * Class Definition
33
- * ------------------------------------------------------------------------
34
- */
35
-
36
- class Button extends BaseComponent {
37
- // Getters
38
-
39
- static get DATA_KEY() {
40
- return DATA_KEY
41
- }
42
-
43
- // Public
44
-
45
- toggle() {
46
- // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
47
- this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE))
48
- }
49
-
50
- // Static
51
-
52
- static jQueryInterface(config) {
53
- return this.each(function () {
54
- let data = Data.get(this, DATA_KEY)
55
-
56
- if (!data) {
57
- data = new Button(this)
58
- }
59
-
60
- if (config === 'toggle') {
61
- data[config]()
62
- }
63
- })
64
- }
65
- }
66
-
67
- /**
68
- * ------------------------------------------------------------------------
69
- * Data Api implementation
70
- * ------------------------------------------------------------------------
71
- */
72
-
73
- EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, event => {
74
- event.preventDefault()
75
-
76
- const button = event.target.closest(SELECTOR_DATA_TOGGLE)
77
-
78
- let data = Data.get(button, DATA_KEY)
79
- if (!data) {
80
- data = new Button(button)
81
- }
82
-
83
- data.toggle()
84
- })
85
-
86
- /**
87
- * ------------------------------------------------------------------------
88
- * jQuery
89
- * ------------------------------------------------------------------------
90
- * add .Button to jQuery only if jQuery is present
91
- */
92
-
93
- defineJQueryPlugin(NAME, Button)
94
-
95
- export default Button
@@ -1,624 +0,0 @@
1
- /**
2
- * --------------------------------------------------------------------------
3
- * Bootstrap (v5.0.0-beta3): carousel.js
4
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
- * --------------------------------------------------------------------------
6
- */
7
-
8
- import {
9
- defineJQueryPlugin,
10
- emulateTransitionEnd,
11
- getElementFromSelector,
12
- getTransitionDurationFromElement,
13
- isRTL,
14
- isVisible,
15
- reflow,
16
- triggerTransitionEnd,
17
- typeCheckConfig
18
- } from './util/index'
19
- import Data from './dom/data'
20
- import EventHandler from './dom/event-handler'
21
- import Manipulator from './dom/manipulator'
22
- import SelectorEngine from './dom/selector-engine'
23
- import BaseComponent from './base-component'
24
-
25
- /**
26
- * ------------------------------------------------------------------------
27
- * Constants
28
- * ------------------------------------------------------------------------
29
- */
30
-
31
- const NAME = 'carousel'
32
- const DATA_KEY = 'bs.carousel'
33
- const EVENT_KEY = `.${DATA_KEY}`
34
- const DATA_API_KEY = '.data-api'
35
-
36
- const ARROW_LEFT_KEY = 'ArrowLeft'
37
- const ARROW_RIGHT_KEY = 'ArrowRight'
38
- const TOUCHEVENT_COMPAT_WAIT = 500 // Time for mouse compat events to fire after touch
39
- const SWIPE_THRESHOLD = 40
40
-
41
- const Default = {
42
- interval: 5000,
43
- keyboard: true,
44
- slide: false,
45
- pause: 'hover',
46
- wrap: true,
47
- touch: true
48
- }
49
-
50
- const DefaultType = {
51
- interval: '(number|boolean)',
52
- keyboard: 'boolean',
53
- slide: '(boolean|string)',
54
- pause: '(string|boolean)',
55
- wrap: 'boolean',
56
- touch: 'boolean'
57
- }
58
-
59
- const ORDER_NEXT = 'next'
60
- const ORDER_PREV = 'prev'
61
- const DIRECTION_LEFT = 'left'
62
- const DIRECTION_RIGHT = 'right'
63
-
64
- const EVENT_SLIDE = `slide${EVENT_KEY}`
65
- const EVENT_SLID = `slid${EVENT_KEY}`
66
- const EVENT_KEYDOWN = `keydown${EVENT_KEY}`
67
- const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY}`
68
- const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY}`
69
- const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`
70
- const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`
71
- const EVENT_TOUCHEND = `touchend${EVENT_KEY}`
72
- const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`
73
- const EVENT_POINTERUP = `pointerup${EVENT_KEY}`
74
- const EVENT_DRAG_START = `dragstart${EVENT_KEY}`
75
- const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
76
- const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
77
-
78
- const CLASS_NAME_CAROUSEL = 'carousel'
79
- const CLASS_NAME_ACTIVE = 'active'
80
- const CLASS_NAME_SLIDE = 'slide'
81
- const CLASS_NAME_END = 'carousel-item-end'
82
- const CLASS_NAME_START = 'carousel-item-start'
83
- const CLASS_NAME_NEXT = 'carousel-item-next'
84
- const CLASS_NAME_PREV = 'carousel-item-prev'
85
- const CLASS_NAME_POINTER_EVENT = 'pointer-event'
86
-
87
- const SELECTOR_ACTIVE = '.active'
88
- const SELECTOR_ACTIVE_ITEM = '.active.carousel-item'
89
- const SELECTOR_ITEM = '.carousel-item'
90
- const SELECTOR_ITEM_IMG = '.carousel-item img'
91
- const SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev'
92
- const SELECTOR_INDICATORS = '.carousel-indicators'
93
- const SELECTOR_INDICATOR = '[data-bs-target]'
94
- const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]'
95
- const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]'
96
-
97
- const POINTER_TYPE_TOUCH = 'touch'
98
- const POINTER_TYPE_PEN = 'pen'
99
-
100
- /**
101
- * ------------------------------------------------------------------------
102
- * Class Definition
103
- * ------------------------------------------------------------------------
104
- */
105
- class Carousel extends BaseComponent {
106
- constructor(element, config) {
107
- super(element)
108
-
109
- this._items = null
110
- this._interval = null
111
- this._activeElement = null
112
- this._isPaused = false
113
- this._isSliding = false
114
- this.touchTimeout = null
115
- this.touchStartX = 0
116
- this.touchDeltaX = 0
117
-
118
- this._config = this._getConfig(config)
119
- this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element)
120
- this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0
121
- this._pointerEvent = Boolean(window.PointerEvent)
122
-
123
- this._addEventListeners()
124
- }
125
-
126
- // Getters
127
-
128
- static get Default() {
129
- return Default
130
- }
131
-
132
- static get DATA_KEY() {
133
- return DATA_KEY
134
- }
135
-
136
- // Public
137
-
138
- next() {
139
- if (!this._isSliding) {
140
- this._slide(ORDER_NEXT)
141
- }
142
- }
143
-
144
- nextWhenVisible() {
145
- // Don't call next when the page isn't visible
146
- // or the carousel or its parent isn't visible
147
- if (!document.hidden && isVisible(this._element)) {
148
- this.next()
149
- }
150
- }
151
-
152
- prev() {
153
- if (!this._isSliding) {
154
- this._slide(ORDER_PREV)
155
- }
156
- }
157
-
158
- pause(event) {
159
- if (!event) {
160
- this._isPaused = true
161
- }
162
-
163
- if (SelectorEngine.findOne(SELECTOR_NEXT_PREV, this._element)) {
164
- triggerTransitionEnd(this._element)
165
- this.cycle(true)
166
- }
167
-
168
- clearInterval(this._interval)
169
- this._interval = null
170
- }
171
-
172
- cycle(event) {
173
- if (!event) {
174
- this._isPaused = false
175
- }
176
-
177
- if (this._interval) {
178
- clearInterval(this._interval)
179
- this._interval = null
180
- }
181
-
182
- if (this._config && this._config.interval && !this._isPaused) {
183
- this._updateInterval()
184
-
185
- this._interval = setInterval(
186
- (document.visibilityState ? this.nextWhenVisible : this.next).bind(this),
187
- this._config.interval
188
- )
189
- }
190
- }
191
-
192
- to(index) {
193
- this._activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element)
194
- const activeIndex = this._getItemIndex(this._activeElement)
195
-
196
- if (index > this._items.length - 1 || index < 0) {
197
- return
198
- }
199
-
200
- if (this._isSliding) {
201
- EventHandler.one(this._element, EVENT_SLID, () => this.to(index))
202
- return
203
- }
204
-
205
- if (activeIndex === index) {
206
- this.pause()
207
- this.cycle()
208
- return
209
- }
210
-
211
- const order = index > activeIndex ?
212
- ORDER_NEXT :
213
- ORDER_PREV
214
-
215
- this._slide(order, this._items[index])
216
- }
217
-
218
- dispose() {
219
- EventHandler.off(this._element, EVENT_KEY)
220
-
221
- this._items = null
222
- this._config = null
223
- this._interval = null
224
- this._isPaused = null
225
- this._isSliding = null
226
- this._activeElement = null
227
- this._indicatorsElement = null
228
-
229
- super.dispose()
230
- }
231
-
232
- // Private
233
-
234
- _getConfig(config) {
235
- config = {
236
- ...Default,
237
- ...config
238
- }
239
- typeCheckConfig(NAME, config, DefaultType)
240
- return config
241
- }
242
-
243
- _handleSwipe() {
244
- const absDeltax = Math.abs(this.touchDeltaX)
245
-
246
- if (absDeltax <= SWIPE_THRESHOLD) {
247
- return
248
- }
249
-
250
- const direction = absDeltax / this.touchDeltaX
251
-
252
- this.touchDeltaX = 0
253
-
254
- if (!direction) {
255
- return
256
- }
257
-
258
- this._slide(direction > 0 ? DIRECTION_RIGHT : DIRECTION_LEFT)
259
- }
260
-
261
- _addEventListeners() {
262
- if (this._config.keyboard) {
263
- EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event))
264
- }
265
-
266
- if (this._config.pause === 'hover') {
267
- EventHandler.on(this._element, EVENT_MOUSEENTER, event => this.pause(event))
268
- EventHandler.on(this._element, EVENT_MOUSELEAVE, event => this.cycle(event))
269
- }
270
-
271
- if (this._config.touch && this._touchSupported) {
272
- this._addTouchEventListeners()
273
- }
274
- }
275
-
276
- _addTouchEventListeners() {
277
- const start = event => {
278
- if (this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) {
279
- this.touchStartX = event.clientX
280
- } else if (!this._pointerEvent) {
281
- this.touchStartX = event.touches[0].clientX
282
- }
283
- }
284
-
285
- const move = event => {
286
- // ensure swiping with one touch and not pinching
287
- this.touchDeltaX = event.touches && event.touches.length > 1 ?
288
- 0 :
289
- event.touches[0].clientX - this.touchStartX
290
- }
291
-
292
- const end = event => {
293
- if (this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) {
294
- this.touchDeltaX = event.clientX - this.touchStartX
295
- }
296
-
297
- this._handleSwipe()
298
- if (this._config.pause === 'hover') {
299
- // If it's a touch-enabled device, mouseenter/leave are fired as
300
- // part of the mouse compatibility events on first tap - the carousel
301
- // would stop cycling until user tapped out of it;
302
- // here, we listen for touchend, explicitly pause the carousel
303
- // (as if it's the second time we tap on it, mouseenter compat event
304
- // is NOT fired) and after a timeout (to allow for mouse compatibility
305
- // events to fire) we explicitly restart cycling
306
-
307
- this.pause()
308
- if (this.touchTimeout) {
309
- clearTimeout(this.touchTimeout)
310
- }
311
-
312
- this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval)
313
- }
314
- }
315
-
316
- SelectorEngine.find(SELECTOR_ITEM_IMG, this._element).forEach(itemImg => {
317
- EventHandler.on(itemImg, EVENT_DRAG_START, e => e.preventDefault())
318
- })
319
-
320
- if (this._pointerEvent) {
321
- EventHandler.on(this._element, EVENT_POINTERDOWN, event => start(event))
322
- EventHandler.on(this._element, EVENT_POINTERUP, event => end(event))
323
-
324
- this._element.classList.add(CLASS_NAME_POINTER_EVENT)
325
- } else {
326
- EventHandler.on(this._element, EVENT_TOUCHSTART, event => start(event))
327
- EventHandler.on(this._element, EVENT_TOUCHMOVE, event => move(event))
328
- EventHandler.on(this._element, EVENT_TOUCHEND, event => end(event))
329
- }
330
- }
331
-
332
- _keydown(event) {
333
- if (/input|textarea/i.test(event.target.tagName)) {
334
- return
335
- }
336
-
337
- if (event.key === ARROW_LEFT_KEY) {
338
- event.preventDefault()
339
- this._slide(DIRECTION_LEFT)
340
- } else if (event.key === ARROW_RIGHT_KEY) {
341
- event.preventDefault()
342
- this._slide(DIRECTION_RIGHT)
343
- }
344
- }
345
-
346
- _getItemIndex(element) {
347
- this._items = element && element.parentNode ?
348
- SelectorEngine.find(SELECTOR_ITEM, element.parentNode) :
349
- []
350
-
351
- return this._items.indexOf(element)
352
- }
353
-
354
- _getItemByOrder(order, activeElement) {
355
- const isNext = order === ORDER_NEXT
356
- const isPrev = order === ORDER_PREV
357
- const activeIndex = this._getItemIndex(activeElement)
358
- const lastItemIndex = this._items.length - 1
359
- const isGoingToWrap = (isPrev && activeIndex === 0) || (isNext && activeIndex === lastItemIndex)
360
-
361
- if (isGoingToWrap && !this._config.wrap) {
362
- return activeElement
363
- }
364
-
365
- const delta = isPrev ? -1 : 1
366
- const itemIndex = (activeIndex + delta) % this._items.length
367
-
368
- return itemIndex === -1 ?
369
- this._items[this._items.length - 1] :
370
- this._items[itemIndex]
371
- }
372
-
373
- _triggerSlideEvent(relatedTarget, eventDirectionName) {
374
- const targetIndex = this._getItemIndex(relatedTarget)
375
- const fromIndex = this._getItemIndex(SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element))
376
-
377
- return EventHandler.trigger(this._element, EVENT_SLIDE, {
378
- relatedTarget,
379
- direction: eventDirectionName,
380
- from: fromIndex,
381
- to: targetIndex
382
- })
383
- }
384
-
385
- _setActiveIndicatorElement(element) {
386
- if (this._indicatorsElement) {
387
- const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement)
388
-
389
- activeIndicator.classList.remove(CLASS_NAME_ACTIVE)
390
- activeIndicator.removeAttribute('aria-current')
391
-
392
- const indicators = SelectorEngine.find(SELECTOR_INDICATOR, this._indicatorsElement)
393
-
394
- for (let i = 0; i < indicators.length; i++) {
395
- if (Number.parseInt(indicators[i].getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) {
396
- indicators[i].classList.add(CLASS_NAME_ACTIVE)
397
- indicators[i].setAttribute('aria-current', 'true')
398
- break
399
- }
400
- }
401
- }
402
- }
403
-
404
- _updateInterval() {
405
- const element = this._activeElement || SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element)
406
-
407
- if (!element) {
408
- return
409
- }
410
-
411
- const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10)
412
-
413
- if (elementInterval) {
414
- this._config.defaultInterval = this._config.defaultInterval || this._config.interval
415
- this._config.interval = elementInterval
416
- } else {
417
- this._config.interval = this._config.defaultInterval || this._config.interval
418
- }
419
- }
420
-
421
- _slide(directionOrOrder, element) {
422
- const order = this._directionToOrder(directionOrOrder)
423
- const activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element)
424
- const activeElementIndex = this._getItemIndex(activeElement)
425
- const nextElement = element || this._getItemByOrder(order, activeElement)
426
-
427
- const nextElementIndex = this._getItemIndex(nextElement)
428
- const isCycling = Boolean(this._interval)
429
-
430
- const isNext = order === ORDER_NEXT
431
- const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END
432
- const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV
433
- const eventDirectionName = this._orderToDirection(order)
434
-
435
- if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE)) {
436
- this._isSliding = false
437
- return
438
- }
439
-
440
- const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName)
441
- if (slideEvent.defaultPrevented) {
442
- return
443
- }
444
-
445
- if (!activeElement || !nextElement) {
446
- // Some weirdness is happening, so we bail
447
- return
448
- }
449
-
450
- this._isSliding = true
451
-
452
- if (isCycling) {
453
- this.pause()
454
- }
455
-
456
- this._setActiveIndicatorElement(nextElement)
457
- this._activeElement = nextElement
458
-
459
- if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
460
- nextElement.classList.add(orderClassName)
461
-
462
- reflow(nextElement)
463
-
464
- activeElement.classList.add(directionalClassName)
465
- nextElement.classList.add(directionalClassName)
466
-
467
- const transitionDuration = getTransitionDurationFromElement(activeElement)
468
-
469
- EventHandler.one(activeElement, 'transitionend', () => {
470
- nextElement.classList.remove(directionalClassName, orderClassName)
471
- nextElement.classList.add(CLASS_NAME_ACTIVE)
472
-
473
- activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName)
474
-
475
- this._isSliding = false
476
-
477
- setTimeout(() => {
478
- EventHandler.trigger(this._element, EVENT_SLID, {
479
- relatedTarget: nextElement,
480
- direction: eventDirectionName,
481
- from: activeElementIndex,
482
- to: nextElementIndex
483
- })
484
- }, 0)
485
- })
486
-
487
- emulateTransitionEnd(activeElement, transitionDuration)
488
- } else {
489
- activeElement.classList.remove(CLASS_NAME_ACTIVE)
490
- nextElement.classList.add(CLASS_NAME_ACTIVE)
491
-
492
- this._isSliding = false
493
- EventHandler.trigger(this._element, EVENT_SLID, {
494
- relatedTarget: nextElement,
495
- direction: eventDirectionName,
496
- from: activeElementIndex,
497
- to: nextElementIndex
498
- })
499
- }
500
-
501
- if (isCycling) {
502
- this.cycle()
503
- }
504
- }
505
-
506
- _directionToOrder(direction) {
507
- if (![DIRECTION_RIGHT, DIRECTION_LEFT].includes(direction)) {
508
- return direction
509
- }
510
-
511
- if (isRTL()) {
512
- return direction === DIRECTION_RIGHT ? ORDER_PREV : ORDER_NEXT
513
- }
514
-
515
- return direction === DIRECTION_RIGHT ? ORDER_NEXT : ORDER_PREV
516
- }
517
-
518
- _orderToDirection(order) {
519
- if (![ORDER_NEXT, ORDER_PREV].includes(order)) {
520
- return order
521
- }
522
-
523
- if (isRTL()) {
524
- return order === ORDER_NEXT ? DIRECTION_LEFT : DIRECTION_RIGHT
525
- }
526
-
527
- return order === ORDER_NEXT ? DIRECTION_RIGHT : DIRECTION_LEFT
528
- }
529
-
530
- // Static
531
-
532
- static carouselInterface(element, config) {
533
- let data = Data.get(element, DATA_KEY)
534
- let _config = {
535
- ...Default,
536
- ...Manipulator.getDataAttributes(element)
537
- }
538
-
539
- if (typeof config === 'object') {
540
- _config = {
541
- ..._config,
542
- ...config
543
- }
544
- }
545
-
546
- const action = typeof config === 'string' ? config : _config.slide
547
-
548
- if (!data) {
549
- data = new Carousel(element, _config)
550
- }
551
-
552
- if (typeof config === 'number') {
553
- data.to(config)
554
- } else if (typeof action === 'string') {
555
- if (typeof data[action] === 'undefined') {
556
- throw new TypeError(`No method named "${action}"`)
557
- }
558
-
559
- data[action]()
560
- } else if (_config.interval && _config.ride) {
561
- data.pause()
562
- data.cycle()
563
- }
564
- }
565
-
566
- static jQueryInterface(config) {
567
- return this.each(function () {
568
- Carousel.carouselInterface(this, config)
569
- })
570
- }
571
-
572
- static dataApiClickHandler(event) {
573
- const target = getElementFromSelector(this)
574
-
575
- if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
576
- return
577
- }
578
-
579
- const config = {
580
- ...Manipulator.getDataAttributes(target),
581
- ...Manipulator.getDataAttributes(this)
582
- }
583
- const slideIndex = this.getAttribute('data-bs-slide-to')
584
-
585
- if (slideIndex) {
586
- config.interval = false
587
- }
588
-
589
- Carousel.carouselInterface(target, config)
590
-
591
- if (slideIndex) {
592
- Data.get(target, DATA_KEY).to(slideIndex)
593
- }
594
-
595
- event.preventDefault()
596
- }
597
- }
598
-
599
- /**
600
- * ------------------------------------------------------------------------
601
- * Data Api implementation
602
- * ------------------------------------------------------------------------
603
- */
604
-
605
- EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler)
606
-
607
- EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
608
- const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE)
609
-
610
- for (let i = 0, len = carousels.length; i < len; i++) {
611
- Carousel.carouselInterface(carousels[i], Data.get(carousels[i], DATA_KEY))
612
- }
613
- })
614
-
615
- /**
616
- * ------------------------------------------------------------------------
617
- * jQuery
618
- * ------------------------------------------------------------------------
619
- * add .Carousel to jQuery only if jQuery is present
620
- */
621
-
622
- defineJQueryPlugin(NAME, Carousel)
623
-
624
- export default Carousel