publishing_platform_publishing_components 0.1.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.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +2 -0
- data/Rakefile +41 -0
- data/app/assets/builds/gemkeep +0 -0
- data/app/assets/config/publishing_platform_publishing_components_manifest.js +2 -0
- data/app/assets/images/publishing_platform_publishing_components/gemkeep +0 -0
- data/app/assets/stylesheets/publishing_platform_publishing_components/_all_components.scss +3 -0
- data/app/assets/stylesheets/publishing_platform_publishing_components/components/_attachment.scss +117 -0
- data/app/assets/stylesheets/publishing_platform_publishing_components/components/_summary-list.scss +169 -0
- data/app/controllers/publishing_platform_publishing_components/application_controller.rb +4 -0
- data/app/helpers/publishing_platform_publishing_components/application_helper.rb +4 -0
- data/app/models/publishing_platform_publishing_components/component_doc.rb +90 -0
- data/app/models/publishing_platform_publishing_components/component_docs.rb +57 -0
- data/app/models/publishing_platform_publishing_components/component_example.rb +104 -0
- data/app/models/publishing_platform_publishing_components/shared_accessibility_criteria.rb +37 -0
- data/app/views/publishing_platform_publishing_components/component_doc/_component_output.html.erb +15 -0
- data/app/views/publishing_platform_publishing_components/components/_attachment.html.erb +91 -0
- data/app/views/publishing_platform_publishing_components/components/_error_summary.html.erb +38 -0
- data/app/views/publishing_platform_publishing_components/components/_summary_list.html.erb +135 -0
- data/app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_document.html.erb +3 -0
- data/app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_external.html.erb +3 -0
- data/app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_generic.html.erb +4 -0
- data/app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_html.html.erb +3 -0
- data/app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_pdf.html.erb +3 -0
- data/app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_spreadsheet.html.erb +5 -0
- data/app/views/publishing_platform_publishing_components/components/docs/attachment.yml +104 -0
- data/app/views/publishing_platform_publishing_components/components/docs/error_summary.yml +51 -0
- data/app/views/publishing_platform_publishing_components/components/docs/summary_list.yml +137 -0
- data/config/initializers/assets.rb +24 -0
- data/config/routes.rb +2 -0
- data/lib/publishing_platform_publishing_components/config.rb +25 -0
- data/lib/publishing_platform_publishing_components/engine.rb +5 -0
- data/lib/publishing_platform_publishing_components/presenters/attachment_helper.rb +176 -0
- data/lib/publishing_platform_publishing_components/presenters/component_wrapper_helper.rb +290 -0
- data/lib/publishing_platform_publishing_components/presenters/shared_helper.rb +24 -0
- data/lib/publishing_platform_publishing_components/version.rb +3 -0
- data/lib/publishing_platform_publishing_components.rb +10 -0
- data/lib/tasks/publishing_platform_publishing_components_tasks.rake +4 -0
- data/node_modules/bootstrap/LICENSE +21 -0
- data/node_modules/bootstrap/README.md +246 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.css +4085 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.min.css +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.css +4084 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.min.css +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.css +601 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.min.css +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.css +598 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.min.css +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.css +5406 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.min.css +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.css +5397 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.min.css +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap.css +12048 -0
- data/node_modules/bootstrap/dist/css/bootstrap.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap.min.css +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap.rtl.css +12021 -0
- data/node_modules/bootstrap/dist/css/bootstrap.rtl.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap.rtl.min.css +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap.rtl.min.css.map +1 -0
- data/node_modules/bootstrap/dist/js/bootstrap.bundle.js +6312 -0
- data/node_modules/bootstrap/dist/js/bootstrap.bundle.js.map +1 -0
- data/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js +7 -0
- data/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js.map +1 -0
- data/node_modules/bootstrap/dist/js/bootstrap.esm.js +4447 -0
- data/node_modules/bootstrap/dist/js/bootstrap.esm.js.map +1 -0
- data/node_modules/bootstrap/dist/js/bootstrap.esm.min.js +7 -0
- data/node_modules/bootstrap/dist/js/bootstrap.esm.min.js.map +1 -0
- data/node_modules/bootstrap/dist/js/bootstrap.js +4494 -0
- data/node_modules/bootstrap/dist/js/bootstrap.js.map +1 -0
- data/node_modules/bootstrap/dist/js/bootstrap.min.js +7 -0
- data/node_modules/bootstrap/dist/js/bootstrap.min.js.map +1 -0
- data/node_modules/bootstrap/js/dist/alert.js +90 -0
- data/node_modules/bootstrap/js/dist/alert.js.map +1 -0
- data/node_modules/bootstrap/js/dist/base-component.js +86 -0
- data/node_modules/bootstrap/js/dist/base-component.js.map +1 -0
- data/node_modules/bootstrap/js/dist/button.js +79 -0
- data/node_modules/bootstrap/js/dist/button.js.map +1 -0
- data/node_modules/bootstrap/js/dist/carousel.js +388 -0
- data/node_modules/bootstrap/js/dist/carousel.js.map +1 -0
- data/node_modules/bootstrap/js/dist/collapse.js +249 -0
- data/node_modules/bootstrap/js/dist/collapse.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dom/data.js +63 -0
- data/node_modules/bootstrap/js/dist/dom/data.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dom/event-handler.js +237 -0
- data/node_modules/bootstrap/js/dist/dom/event-handler.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dom/manipulator.js +72 -0
- data/node_modules/bootstrap/js/dist/dom/manipulator.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dom/selector-engine.js +104 -0
- data/node_modules/bootstrap/js/dist/dom/selector-engine.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dropdown.js +402 -0
- data/node_modules/bootstrap/js/dist/dropdown.js.map +1 -0
- data/node_modules/bootstrap/js/dist/modal.js +320 -0
- data/node_modules/bootstrap/js/dist/modal.js.map +1 -0
- data/node_modules/bootstrap/js/dist/offcanvas.js +246 -0
- data/node_modules/bootstrap/js/dist/offcanvas.js.map +1 -0
- data/node_modules/bootstrap/js/dist/popover.js +96 -0
- data/node_modules/bootstrap/js/dist/popover.js.map +1 -0
- data/node_modules/bootstrap/js/dist/scrollspy.js +275 -0
- data/node_modules/bootstrap/js/dist/scrollspy.js.map +1 -0
- data/node_modules/bootstrap/js/dist/tab.js +285 -0
- data/node_modules/bootstrap/js/dist/tab.js.map +1 -0
- data/node_modules/bootstrap/js/dist/toast.js +198 -0
- data/node_modules/bootstrap/js/dist/toast.js.map +1 -0
- data/node_modules/bootstrap/js/dist/tooltip.js +546 -0
- data/node_modules/bootstrap/js/dist/tooltip.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/backdrop.js +139 -0
- data/node_modules/bootstrap/js/dist/util/backdrop.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/component-functions.js +42 -0
- data/node_modules/bootstrap/js/dist/util/component-functions.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/config.js +68 -0
- data/node_modules/bootstrap/js/dist/util/config.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/focustrap.js +113 -0
- data/node_modules/bootstrap/js/dist/util/focustrap.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/index.js +281 -0
- data/node_modules/bootstrap/js/dist/util/index.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/sanitizer.js +113 -0
- data/node_modules/bootstrap/js/dist/util/sanitizer.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/scrollbar.js +113 -0
- data/node_modules/bootstrap/js/dist/util/scrollbar.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/swipe.js +135 -0
- data/node_modules/bootstrap/js/dist/util/swipe.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/template-factory.js +151 -0
- data/node_modules/bootstrap/js/dist/util/template-factory.js.map +1 -0
- data/node_modules/bootstrap/js/index.esm.js +19 -0
- data/node_modules/bootstrap/js/index.umd.js +34 -0
- data/node_modules/bootstrap/js/src/alert.js +87 -0
- data/node_modules/bootstrap/js/src/base-component.js +86 -0
- data/node_modules/bootstrap/js/src/button.js +72 -0
- data/node_modules/bootstrap/js/src/carousel.js +474 -0
- data/node_modules/bootstrap/js/src/collapse.js +297 -0
- data/node_modules/bootstrap/js/src/dom/data.js +55 -0
- data/node_modules/bootstrap/js/src/dom/event-handler.js +317 -0
- data/node_modules/bootstrap/js/src/dom/manipulator.js +71 -0
- data/node_modules/bootstrap/js/src/dom/selector-engine.js +126 -0
- data/node_modules/bootstrap/js/src/dropdown.js +455 -0
- data/node_modules/bootstrap/js/src/modal.js +378 -0
- data/node_modules/bootstrap/js/src/offcanvas.js +282 -0
- data/node_modules/bootstrap/js/src/popover.js +97 -0
- data/node_modules/bootstrap/js/src/scrollspy.js +296 -0
- data/node_modules/bootstrap/js/src/tab.js +315 -0
- data/node_modules/bootstrap/js/src/toast.js +224 -0
- data/node_modules/bootstrap/js/src/tooltip.js +633 -0
- data/node_modules/bootstrap/js/src/util/backdrop.js +151 -0
- data/node_modules/bootstrap/js/src/util/component-functions.js +35 -0
- data/node_modules/bootstrap/js/src/util/config.js +65 -0
- data/node_modules/bootstrap/js/src/util/focustrap.js +115 -0
- data/node_modules/bootstrap/js/src/util/index.js +306 -0
- data/node_modules/bootstrap/js/src/util/sanitizer.js +116 -0
- data/node_modules/bootstrap/js/src/util/scrollbar.js +114 -0
- data/node_modules/bootstrap/js/src/util/swipe.js +146 -0
- data/node_modules/bootstrap/js/src/util/template-factory.js +160 -0
- data/node_modules/bootstrap/package.json +210 -0
- data/node_modules/bootstrap/scss/_accordion.scss +153 -0
- data/node_modules/bootstrap/scss/_alert.scss +68 -0
- data/node_modules/bootstrap/scss/_badge.scss +38 -0
- data/node_modules/bootstrap/scss/_breadcrumb.scss +40 -0
- data/node_modules/bootstrap/scss/_button-group.scss +147 -0
- data/node_modules/bootstrap/scss/_buttons.scss +216 -0
- data/node_modules/bootstrap/scss/_card.scss +238 -0
- data/node_modules/bootstrap/scss/_carousel.scss +226 -0
- data/node_modules/bootstrap/scss/_close.scss +66 -0
- data/node_modules/bootstrap/scss/_containers.scss +41 -0
- data/node_modules/bootstrap/scss/_dropdown.scss +250 -0
- data/node_modules/bootstrap/scss/_forms.scss +9 -0
- data/node_modules/bootstrap/scss/_functions.scss +302 -0
- data/node_modules/bootstrap/scss/_grid.scss +39 -0
- data/node_modules/bootstrap/scss/_helpers.scss +12 -0
- data/node_modules/bootstrap/scss/_images.scss +42 -0
- data/node_modules/bootstrap/scss/_list-group.scss +199 -0
- data/node_modules/bootstrap/scss/_maps.scss +174 -0
- data/node_modules/bootstrap/scss/_mixins.scss +42 -0
- data/node_modules/bootstrap/scss/_modal.scss +240 -0
- data/node_modules/bootstrap/scss/_nav.scss +197 -0
- data/node_modules/bootstrap/scss/_navbar.scss +289 -0
- data/node_modules/bootstrap/scss/_offcanvas.scss +147 -0
- data/node_modules/bootstrap/scss/_pagination.scss +109 -0
- data/node_modules/bootstrap/scss/_placeholders.scss +51 -0
- data/node_modules/bootstrap/scss/_popover.scss +196 -0
- data/node_modules/bootstrap/scss/_progress.scss +68 -0
- data/node_modules/bootstrap/scss/_reboot.scss +617 -0
- data/node_modules/bootstrap/scss/_root.scss +187 -0
- data/node_modules/bootstrap/scss/_spinners.scss +86 -0
- data/node_modules/bootstrap/scss/_tables.scss +171 -0
- data/node_modules/bootstrap/scss/_toasts.scss +73 -0
- data/node_modules/bootstrap/scss/_tooltip.scss +119 -0
- data/node_modules/bootstrap/scss/_transitions.scss +27 -0
- data/node_modules/bootstrap/scss/_type.scss +106 -0
- data/node_modules/bootstrap/scss/_utilities.scss +806 -0
- data/node_modules/bootstrap/scss/_variables-dark.scss +102 -0
- data/node_modules/bootstrap/scss/_variables.scss +1753 -0
- data/node_modules/bootstrap/scss/bootstrap-grid.scss +62 -0
- data/node_modules/bootstrap/scss/bootstrap-reboot.scss +10 -0
- data/node_modules/bootstrap/scss/bootstrap-utilities.scss +19 -0
- data/node_modules/bootstrap/scss/bootstrap.scss +52 -0
- data/node_modules/bootstrap/scss/forms/_floating-labels.scss +97 -0
- data/node_modules/bootstrap/scss/forms/_form-check.scss +189 -0
- data/node_modules/bootstrap/scss/forms/_form-control.scss +214 -0
- data/node_modules/bootstrap/scss/forms/_form-range.scss +91 -0
- data/node_modules/bootstrap/scss/forms/_form-select.scss +80 -0
- data/node_modules/bootstrap/scss/forms/_form-text.scss +11 -0
- data/node_modules/bootstrap/scss/forms/_input-group.scss +132 -0
- data/node_modules/bootstrap/scss/forms/_labels.scss +36 -0
- data/node_modules/bootstrap/scss/forms/_validation.scss +12 -0
- data/node_modules/bootstrap/scss/helpers/_clearfix.scss +3 -0
- data/node_modules/bootstrap/scss/helpers/_color-bg.scss +7 -0
- data/node_modules/bootstrap/scss/helpers/_colored-links.scss +30 -0
- data/node_modules/bootstrap/scss/helpers/_focus-ring.scss +5 -0
- data/node_modules/bootstrap/scss/helpers/_icon-link.scss +25 -0
- data/node_modules/bootstrap/scss/helpers/_position.scss +36 -0
- data/node_modules/bootstrap/scss/helpers/_ratio.scss +26 -0
- data/node_modules/bootstrap/scss/helpers/_stacks.scss +15 -0
- data/node_modules/bootstrap/scss/helpers/_stretched-link.scss +15 -0
- data/node_modules/bootstrap/scss/helpers/_text-truncation.scss +7 -0
- data/node_modules/bootstrap/scss/helpers/_visually-hidden.scss +8 -0
- data/node_modules/bootstrap/scss/helpers/_vr.scss +8 -0
- data/node_modules/bootstrap/scss/mixins/_alert.scss +18 -0
- data/node_modules/bootstrap/scss/mixins/_backdrop.scss +14 -0
- data/node_modules/bootstrap/scss/mixins/_banner.scss +7 -0
- data/node_modules/bootstrap/scss/mixins/_border-radius.scss +78 -0
- data/node_modules/bootstrap/scss/mixins/_box-shadow.scss +24 -0
- data/node_modules/bootstrap/scss/mixins/_breakpoints.scss +127 -0
- data/node_modules/bootstrap/scss/mixins/_buttons.scss +70 -0
- data/node_modules/bootstrap/scss/mixins/_caret.scss +69 -0
- data/node_modules/bootstrap/scss/mixins/_clearfix.scss +9 -0
- data/node_modules/bootstrap/scss/mixins/_color-mode.scss +21 -0
- data/node_modules/bootstrap/scss/mixins/_color-scheme.scss +7 -0
- data/node_modules/bootstrap/scss/mixins/_container.scss +11 -0
- data/node_modules/bootstrap/scss/mixins/_deprecate.scss +10 -0
- data/node_modules/bootstrap/scss/mixins/_forms.scss +163 -0
- data/node_modules/bootstrap/scss/mixins/_gradients.scss +47 -0
- data/node_modules/bootstrap/scss/mixins/_grid.scss +151 -0
- data/node_modules/bootstrap/scss/mixins/_image.scss +16 -0
- data/node_modules/bootstrap/scss/mixins/_list-group.scss +26 -0
- data/node_modules/bootstrap/scss/mixins/_lists.scss +7 -0
- data/node_modules/bootstrap/scss/mixins/_pagination.scss +10 -0
- data/node_modules/bootstrap/scss/mixins/_reset-text.scss +17 -0
- data/node_modules/bootstrap/scss/mixins/_resize.scss +6 -0
- data/node_modules/bootstrap/scss/mixins/_table-variants.scss +24 -0
- data/node_modules/bootstrap/scss/mixins/_text-truncate.scss +8 -0
- data/node_modules/bootstrap/scss/mixins/_transition.scss +26 -0
- data/node_modules/bootstrap/scss/mixins/_utilities.scss +97 -0
- data/node_modules/bootstrap/scss/mixins/_visually-hidden.scss +38 -0
- data/node_modules/bootstrap/scss/utilities/_api.scss +47 -0
- data/node_modules/bootstrap/scss/vendor/_rfs.scss +348 -0
- metadata +448 -0
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap carousel.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import BaseComponent from './base-component.js'
|
|
9
|
+
import EventHandler from './dom/event-handler.js'
|
|
10
|
+
import Manipulator from './dom/manipulator.js'
|
|
11
|
+
import SelectorEngine from './dom/selector-engine.js'
|
|
12
|
+
import {
|
|
13
|
+
defineJQueryPlugin,
|
|
14
|
+
getNextActiveElement,
|
|
15
|
+
isRTL,
|
|
16
|
+
isVisible,
|
|
17
|
+
reflow,
|
|
18
|
+
triggerTransitionEnd
|
|
19
|
+
} from './util/index.js'
|
|
20
|
+
import Swipe from './util/swipe.js'
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Constants
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const NAME = 'carousel'
|
|
27
|
+
const DATA_KEY = 'bs.carousel'
|
|
28
|
+
const EVENT_KEY = `.${DATA_KEY}`
|
|
29
|
+
const DATA_API_KEY = '.data-api'
|
|
30
|
+
|
|
31
|
+
const ARROW_LEFT_KEY = 'ArrowLeft'
|
|
32
|
+
const ARROW_RIGHT_KEY = 'ArrowRight'
|
|
33
|
+
const TOUCHEVENT_COMPAT_WAIT = 500 // Time for mouse compat events to fire after touch
|
|
34
|
+
|
|
35
|
+
const ORDER_NEXT = 'next'
|
|
36
|
+
const ORDER_PREV = 'prev'
|
|
37
|
+
const DIRECTION_LEFT = 'left'
|
|
38
|
+
const DIRECTION_RIGHT = 'right'
|
|
39
|
+
|
|
40
|
+
const EVENT_SLIDE = `slide${EVENT_KEY}`
|
|
41
|
+
const EVENT_SLID = `slid${EVENT_KEY}`
|
|
42
|
+
const EVENT_KEYDOWN = `keydown${EVENT_KEY}`
|
|
43
|
+
const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY}`
|
|
44
|
+
const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY}`
|
|
45
|
+
const EVENT_DRAG_START = `dragstart${EVENT_KEY}`
|
|
46
|
+
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
|
|
47
|
+
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
|
|
48
|
+
|
|
49
|
+
const CLASS_NAME_CAROUSEL = 'carousel'
|
|
50
|
+
const CLASS_NAME_ACTIVE = 'active'
|
|
51
|
+
const CLASS_NAME_SLIDE = 'slide'
|
|
52
|
+
const CLASS_NAME_END = 'carousel-item-end'
|
|
53
|
+
const CLASS_NAME_START = 'carousel-item-start'
|
|
54
|
+
const CLASS_NAME_NEXT = 'carousel-item-next'
|
|
55
|
+
const CLASS_NAME_PREV = 'carousel-item-prev'
|
|
56
|
+
|
|
57
|
+
const SELECTOR_ACTIVE = '.active'
|
|
58
|
+
const SELECTOR_ITEM = '.carousel-item'
|
|
59
|
+
const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM
|
|
60
|
+
const SELECTOR_ITEM_IMG = '.carousel-item img'
|
|
61
|
+
const SELECTOR_INDICATORS = '.carousel-indicators'
|
|
62
|
+
const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]'
|
|
63
|
+
const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]'
|
|
64
|
+
|
|
65
|
+
const KEY_TO_DIRECTION = {
|
|
66
|
+
[ARROW_LEFT_KEY]: DIRECTION_RIGHT,
|
|
67
|
+
[ARROW_RIGHT_KEY]: DIRECTION_LEFT
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const Default = {
|
|
71
|
+
interval: 5000,
|
|
72
|
+
keyboard: true,
|
|
73
|
+
pause: 'hover',
|
|
74
|
+
ride: false,
|
|
75
|
+
touch: true,
|
|
76
|
+
wrap: true
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const DefaultType = {
|
|
80
|
+
interval: '(number|boolean)', // TODO:v6 remove boolean support
|
|
81
|
+
keyboard: 'boolean',
|
|
82
|
+
pause: '(string|boolean)',
|
|
83
|
+
ride: '(boolean|string)',
|
|
84
|
+
touch: 'boolean',
|
|
85
|
+
wrap: 'boolean'
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Class definition
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
class Carousel extends BaseComponent {
|
|
93
|
+
constructor(element, config) {
|
|
94
|
+
super(element, config)
|
|
95
|
+
|
|
96
|
+
this._interval = null
|
|
97
|
+
this._activeElement = null
|
|
98
|
+
this._isSliding = false
|
|
99
|
+
this.touchTimeout = null
|
|
100
|
+
this._swipeHelper = null
|
|
101
|
+
|
|
102
|
+
this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element)
|
|
103
|
+
this._addEventListeners()
|
|
104
|
+
|
|
105
|
+
if (this._config.ride === CLASS_NAME_CAROUSEL) {
|
|
106
|
+
this.cycle()
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Getters
|
|
111
|
+
static get Default() {
|
|
112
|
+
return Default
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static get DefaultType() {
|
|
116
|
+
return DefaultType
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static get NAME() {
|
|
120
|
+
return NAME
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Public
|
|
124
|
+
next() {
|
|
125
|
+
this._slide(ORDER_NEXT)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
nextWhenVisible() {
|
|
129
|
+
// FIXME TODO use `document.visibilityState`
|
|
130
|
+
// Don't call next when the page isn't visible
|
|
131
|
+
// or the carousel or its parent isn't visible
|
|
132
|
+
if (!document.hidden && isVisible(this._element)) {
|
|
133
|
+
this.next()
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
prev() {
|
|
138
|
+
this._slide(ORDER_PREV)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
pause() {
|
|
142
|
+
if (this._isSliding) {
|
|
143
|
+
triggerTransitionEnd(this._element)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
this._clearInterval()
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
cycle() {
|
|
150
|
+
this._clearInterval()
|
|
151
|
+
this._updateInterval()
|
|
152
|
+
|
|
153
|
+
this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
_maybeEnableCycle() {
|
|
157
|
+
if (!this._config.ride) {
|
|
158
|
+
return
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (this._isSliding) {
|
|
162
|
+
EventHandler.one(this._element, EVENT_SLID, () => this.cycle())
|
|
163
|
+
return
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this.cycle()
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
to(index) {
|
|
170
|
+
const items = this._getItems()
|
|
171
|
+
if (index > items.length - 1 || index < 0) {
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (this._isSliding) {
|
|
176
|
+
EventHandler.one(this._element, EVENT_SLID, () => this.to(index))
|
|
177
|
+
return
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const activeIndex = this._getItemIndex(this._getActive())
|
|
181
|
+
if (activeIndex === index) {
|
|
182
|
+
return
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV
|
|
186
|
+
|
|
187
|
+
this._slide(order, items[index])
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
dispose() {
|
|
191
|
+
if (this._swipeHelper) {
|
|
192
|
+
this._swipeHelper.dispose()
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
super.dispose()
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Private
|
|
199
|
+
_configAfterMerge(config) {
|
|
200
|
+
config.defaultInterval = config.interval
|
|
201
|
+
return config
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
_addEventListeners() {
|
|
205
|
+
if (this._config.keyboard) {
|
|
206
|
+
EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event))
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (this._config.pause === 'hover') {
|
|
210
|
+
EventHandler.on(this._element, EVENT_MOUSEENTER, () => this.pause())
|
|
211
|
+
EventHandler.on(this._element, EVENT_MOUSELEAVE, () => this._maybeEnableCycle())
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (this._config.touch && Swipe.isSupported()) {
|
|
215
|
+
this._addTouchEventListeners()
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
_addTouchEventListeners() {
|
|
220
|
+
for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) {
|
|
221
|
+
EventHandler.on(img, EVENT_DRAG_START, event => event.preventDefault())
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const endCallBack = () => {
|
|
225
|
+
if (this._config.pause !== 'hover') {
|
|
226
|
+
return
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// If it's a touch-enabled device, mouseenter/leave are fired as
|
|
230
|
+
// part of the mouse compatibility events on first tap - the carousel
|
|
231
|
+
// would stop cycling until user tapped out of it;
|
|
232
|
+
// here, we listen for touchend, explicitly pause the carousel
|
|
233
|
+
// (as if it's the second time we tap on it, mouseenter compat event
|
|
234
|
+
// is NOT fired) and after a timeout (to allow for mouse compatibility
|
|
235
|
+
// events to fire) we explicitly restart cycling
|
|
236
|
+
|
|
237
|
+
this.pause()
|
|
238
|
+
if (this.touchTimeout) {
|
|
239
|
+
clearTimeout(this.touchTimeout)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const swipeConfig = {
|
|
246
|
+
leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
|
|
247
|
+
rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
|
|
248
|
+
endCallback: endCallBack
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
this._swipeHelper = new Swipe(this._element, swipeConfig)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
_keydown(event) {
|
|
255
|
+
if (/input|textarea/i.test(event.target.tagName)) {
|
|
256
|
+
return
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const direction = KEY_TO_DIRECTION[event.key]
|
|
260
|
+
if (direction) {
|
|
261
|
+
event.preventDefault()
|
|
262
|
+
this._slide(this._directionToOrder(direction))
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
_getItemIndex(element) {
|
|
267
|
+
return this._getItems().indexOf(element)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
_setActiveIndicatorElement(index) {
|
|
271
|
+
if (!this._indicatorsElement) {
|
|
272
|
+
return
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement)
|
|
276
|
+
|
|
277
|
+
activeIndicator.classList.remove(CLASS_NAME_ACTIVE)
|
|
278
|
+
activeIndicator.removeAttribute('aria-current')
|
|
279
|
+
|
|
280
|
+
const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement)
|
|
281
|
+
|
|
282
|
+
if (newActiveIndicator) {
|
|
283
|
+
newActiveIndicator.classList.add(CLASS_NAME_ACTIVE)
|
|
284
|
+
newActiveIndicator.setAttribute('aria-current', 'true')
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
_updateInterval() {
|
|
289
|
+
const element = this._activeElement || this._getActive()
|
|
290
|
+
|
|
291
|
+
if (!element) {
|
|
292
|
+
return
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10)
|
|
296
|
+
|
|
297
|
+
this._config.interval = elementInterval || this._config.defaultInterval
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
_slide(order, element = null) {
|
|
301
|
+
if (this._isSliding) {
|
|
302
|
+
return
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const activeElement = this._getActive()
|
|
306
|
+
const isNext = order === ORDER_NEXT
|
|
307
|
+
const nextElement = element || getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap)
|
|
308
|
+
|
|
309
|
+
if (nextElement === activeElement) {
|
|
310
|
+
return
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const nextElementIndex = this._getItemIndex(nextElement)
|
|
314
|
+
|
|
315
|
+
const triggerEvent = eventName => {
|
|
316
|
+
return EventHandler.trigger(this._element, eventName, {
|
|
317
|
+
relatedTarget: nextElement,
|
|
318
|
+
direction: this._orderToDirection(order),
|
|
319
|
+
from: this._getItemIndex(activeElement),
|
|
320
|
+
to: nextElementIndex
|
|
321
|
+
})
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const slideEvent = triggerEvent(EVENT_SLIDE)
|
|
325
|
+
|
|
326
|
+
if (slideEvent.defaultPrevented) {
|
|
327
|
+
return
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (!activeElement || !nextElement) {
|
|
331
|
+
// Some weirdness is happening, so we bail
|
|
332
|
+
// TODO: change tests that use empty divs to avoid this check
|
|
333
|
+
return
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const isCycling = Boolean(this._interval)
|
|
337
|
+
this.pause()
|
|
338
|
+
|
|
339
|
+
this._isSliding = true
|
|
340
|
+
|
|
341
|
+
this._setActiveIndicatorElement(nextElementIndex)
|
|
342
|
+
this._activeElement = nextElement
|
|
343
|
+
|
|
344
|
+
const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END
|
|
345
|
+
const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV
|
|
346
|
+
|
|
347
|
+
nextElement.classList.add(orderClassName)
|
|
348
|
+
|
|
349
|
+
reflow(nextElement)
|
|
350
|
+
|
|
351
|
+
activeElement.classList.add(directionalClassName)
|
|
352
|
+
nextElement.classList.add(directionalClassName)
|
|
353
|
+
|
|
354
|
+
const completeCallBack = () => {
|
|
355
|
+
nextElement.classList.remove(directionalClassName, orderClassName)
|
|
356
|
+
nextElement.classList.add(CLASS_NAME_ACTIVE)
|
|
357
|
+
|
|
358
|
+
activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName)
|
|
359
|
+
|
|
360
|
+
this._isSliding = false
|
|
361
|
+
|
|
362
|
+
triggerEvent(EVENT_SLID)
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
this._queueCallback(completeCallBack, activeElement, this._isAnimated())
|
|
366
|
+
|
|
367
|
+
if (isCycling) {
|
|
368
|
+
this.cycle()
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
_isAnimated() {
|
|
373
|
+
return this._element.classList.contains(CLASS_NAME_SLIDE)
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
_getActive() {
|
|
377
|
+
return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element)
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
_getItems() {
|
|
381
|
+
return SelectorEngine.find(SELECTOR_ITEM, this._element)
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
_clearInterval() {
|
|
385
|
+
if (this._interval) {
|
|
386
|
+
clearInterval(this._interval)
|
|
387
|
+
this._interval = null
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
_directionToOrder(direction) {
|
|
392
|
+
if (isRTL()) {
|
|
393
|
+
return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
_orderToDirection(order) {
|
|
400
|
+
if (isRTL()) {
|
|
401
|
+
return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Static
|
|
408
|
+
static jQueryInterface(config) {
|
|
409
|
+
return this.each(function () {
|
|
410
|
+
const data = Carousel.getOrCreateInstance(this, config)
|
|
411
|
+
|
|
412
|
+
if (typeof config === 'number') {
|
|
413
|
+
data.to(config)
|
|
414
|
+
return
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (typeof config === 'string') {
|
|
418
|
+
if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
|
|
419
|
+
throw new TypeError(`No method named "${config}"`)
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
data[config]()
|
|
423
|
+
}
|
|
424
|
+
})
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Data API implementation
|
|
430
|
+
*/
|
|
431
|
+
|
|
432
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, function (event) {
|
|
433
|
+
const target = SelectorEngine.getElementFromSelector(this)
|
|
434
|
+
|
|
435
|
+
if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
|
|
436
|
+
return
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
event.preventDefault()
|
|
440
|
+
|
|
441
|
+
const carousel = Carousel.getOrCreateInstance(target)
|
|
442
|
+
const slideIndex = this.getAttribute('data-bs-slide-to')
|
|
443
|
+
|
|
444
|
+
if (slideIndex) {
|
|
445
|
+
carousel.to(slideIndex)
|
|
446
|
+
carousel._maybeEnableCycle()
|
|
447
|
+
return
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
|
|
451
|
+
carousel.next()
|
|
452
|
+
carousel._maybeEnableCycle()
|
|
453
|
+
return
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
carousel.prev()
|
|
457
|
+
carousel._maybeEnableCycle()
|
|
458
|
+
})
|
|
459
|
+
|
|
460
|
+
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
|
|
461
|
+
const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE)
|
|
462
|
+
|
|
463
|
+
for (const carousel of carousels) {
|
|
464
|
+
Carousel.getOrCreateInstance(carousel)
|
|
465
|
+
}
|
|
466
|
+
})
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* jQuery
|
|
470
|
+
*/
|
|
471
|
+
|
|
472
|
+
defineJQueryPlugin(Carousel)
|
|
473
|
+
|
|
474
|
+
export default Carousel
|