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,378 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap modal.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 SelectorEngine from './dom/selector-engine.js'
|
|
11
|
+
import Backdrop from './util/backdrop.js'
|
|
12
|
+
import { enableDismissTrigger } from './util/component-functions.js'
|
|
13
|
+
import FocusTrap from './util/focustrap.js'
|
|
14
|
+
import {
|
|
15
|
+
defineJQueryPlugin, isRTL, isVisible, reflow
|
|
16
|
+
} from './util/index.js'
|
|
17
|
+
import ScrollBarHelper from './util/scrollbar.js'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Constants
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const NAME = 'modal'
|
|
24
|
+
const DATA_KEY = 'bs.modal'
|
|
25
|
+
const EVENT_KEY = `.${DATA_KEY}`
|
|
26
|
+
const DATA_API_KEY = '.data-api'
|
|
27
|
+
const ESCAPE_KEY = 'Escape'
|
|
28
|
+
|
|
29
|
+
const EVENT_HIDE = `hide${EVENT_KEY}`
|
|
30
|
+
const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`
|
|
31
|
+
const EVENT_HIDDEN = `hidden${EVENT_KEY}`
|
|
32
|
+
const EVENT_SHOW = `show${EVENT_KEY}`
|
|
33
|
+
const EVENT_SHOWN = `shown${EVENT_KEY}`
|
|
34
|
+
const EVENT_RESIZE = `resize${EVENT_KEY}`
|
|
35
|
+
const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`
|
|
36
|
+
const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY}`
|
|
37
|
+
const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`
|
|
38
|
+
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
|
|
39
|
+
|
|
40
|
+
const CLASS_NAME_OPEN = 'modal-open'
|
|
41
|
+
const CLASS_NAME_FADE = 'fade'
|
|
42
|
+
const CLASS_NAME_SHOW = 'show'
|
|
43
|
+
const CLASS_NAME_STATIC = 'modal-static'
|
|
44
|
+
|
|
45
|
+
const OPEN_SELECTOR = '.modal.show'
|
|
46
|
+
const SELECTOR_DIALOG = '.modal-dialog'
|
|
47
|
+
const SELECTOR_MODAL_BODY = '.modal-body'
|
|
48
|
+
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="modal"]'
|
|
49
|
+
|
|
50
|
+
const Default = {
|
|
51
|
+
backdrop: true,
|
|
52
|
+
focus: true,
|
|
53
|
+
keyboard: true
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const DefaultType = {
|
|
57
|
+
backdrop: '(boolean|string)',
|
|
58
|
+
focus: 'boolean',
|
|
59
|
+
keyboard: 'boolean'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Class definition
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
class Modal extends BaseComponent {
|
|
67
|
+
constructor(element, config) {
|
|
68
|
+
super(element, config)
|
|
69
|
+
|
|
70
|
+
this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element)
|
|
71
|
+
this._backdrop = this._initializeBackDrop()
|
|
72
|
+
this._focustrap = this._initializeFocusTrap()
|
|
73
|
+
this._isShown = false
|
|
74
|
+
this._isTransitioning = false
|
|
75
|
+
this._scrollBar = new ScrollBarHelper()
|
|
76
|
+
|
|
77
|
+
this._addEventListeners()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Getters
|
|
81
|
+
static get Default() {
|
|
82
|
+
return Default
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static get DefaultType() {
|
|
86
|
+
return DefaultType
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static get NAME() {
|
|
90
|
+
return NAME
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Public
|
|
94
|
+
toggle(relatedTarget) {
|
|
95
|
+
return this._isShown ? this.hide() : this.show(relatedTarget)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
show(relatedTarget) {
|
|
99
|
+
if (this._isShown || this._isTransitioning) {
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, {
|
|
104
|
+
relatedTarget
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
if (showEvent.defaultPrevented) {
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
this._isShown = true
|
|
112
|
+
this._isTransitioning = true
|
|
113
|
+
|
|
114
|
+
this._scrollBar.hide()
|
|
115
|
+
|
|
116
|
+
document.body.classList.add(CLASS_NAME_OPEN)
|
|
117
|
+
|
|
118
|
+
this._adjustDialog()
|
|
119
|
+
|
|
120
|
+
this._backdrop.show(() => this._showElement(relatedTarget))
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
hide() {
|
|
124
|
+
if (!this._isShown || this._isTransitioning) {
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE)
|
|
129
|
+
|
|
130
|
+
if (hideEvent.defaultPrevented) {
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
this._isShown = false
|
|
135
|
+
this._isTransitioning = true
|
|
136
|
+
this._focustrap.deactivate()
|
|
137
|
+
|
|
138
|
+
this._element.classList.remove(CLASS_NAME_SHOW)
|
|
139
|
+
|
|
140
|
+
this._queueCallback(() => this._hideModal(), this._element, this._isAnimated())
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
dispose() {
|
|
144
|
+
EventHandler.off(window, EVENT_KEY)
|
|
145
|
+
EventHandler.off(this._dialog, EVENT_KEY)
|
|
146
|
+
|
|
147
|
+
this._backdrop.dispose()
|
|
148
|
+
this._focustrap.deactivate()
|
|
149
|
+
|
|
150
|
+
super.dispose()
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
handleUpdate() {
|
|
154
|
+
this._adjustDialog()
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Private
|
|
158
|
+
_initializeBackDrop() {
|
|
159
|
+
return new Backdrop({
|
|
160
|
+
isVisible: Boolean(this._config.backdrop), // 'static' option will be translated to true, and booleans will keep their value,
|
|
161
|
+
isAnimated: this._isAnimated()
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
_initializeFocusTrap() {
|
|
166
|
+
return new FocusTrap({
|
|
167
|
+
trapElement: this._element
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
_showElement(relatedTarget) {
|
|
172
|
+
// try to append dynamic modal
|
|
173
|
+
if (!document.body.contains(this._element)) {
|
|
174
|
+
document.body.append(this._element)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
this._element.style.display = 'block'
|
|
178
|
+
this._element.removeAttribute('aria-hidden')
|
|
179
|
+
this._element.setAttribute('aria-modal', true)
|
|
180
|
+
this._element.setAttribute('role', 'dialog')
|
|
181
|
+
this._element.scrollTop = 0
|
|
182
|
+
|
|
183
|
+
const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog)
|
|
184
|
+
if (modalBody) {
|
|
185
|
+
modalBody.scrollTop = 0
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
reflow(this._element)
|
|
189
|
+
|
|
190
|
+
this._element.classList.add(CLASS_NAME_SHOW)
|
|
191
|
+
|
|
192
|
+
const transitionComplete = () => {
|
|
193
|
+
if (this._config.focus) {
|
|
194
|
+
this._focustrap.activate()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
this._isTransitioning = false
|
|
198
|
+
EventHandler.trigger(this._element, EVENT_SHOWN, {
|
|
199
|
+
relatedTarget
|
|
200
|
+
})
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
this._queueCallback(transitionComplete, this._dialog, this._isAnimated())
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
_addEventListeners() {
|
|
207
|
+
EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
|
|
208
|
+
if (event.key !== ESCAPE_KEY) {
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (this._config.keyboard) {
|
|
213
|
+
this.hide()
|
|
214
|
+
return
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
this._triggerBackdropTransition()
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
EventHandler.on(window, EVENT_RESIZE, () => {
|
|
221
|
+
if (this._isShown && !this._isTransitioning) {
|
|
222
|
+
this._adjustDialog()
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => {
|
|
227
|
+
// a bad trick to segregate clicks that may start inside dialog but end outside, and avoid listen to scrollbar clicks
|
|
228
|
+
EventHandler.one(this._element, EVENT_CLICK_DISMISS, event2 => {
|
|
229
|
+
if (this._element !== event.target || this._element !== event2.target) {
|
|
230
|
+
return
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (this._config.backdrop === 'static') {
|
|
234
|
+
this._triggerBackdropTransition()
|
|
235
|
+
return
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (this._config.backdrop) {
|
|
239
|
+
this.hide()
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
})
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
_hideModal() {
|
|
246
|
+
this._element.style.display = 'none'
|
|
247
|
+
this._element.setAttribute('aria-hidden', true)
|
|
248
|
+
this._element.removeAttribute('aria-modal')
|
|
249
|
+
this._element.removeAttribute('role')
|
|
250
|
+
this._isTransitioning = false
|
|
251
|
+
|
|
252
|
+
this._backdrop.hide(() => {
|
|
253
|
+
document.body.classList.remove(CLASS_NAME_OPEN)
|
|
254
|
+
this._resetAdjustments()
|
|
255
|
+
this._scrollBar.reset()
|
|
256
|
+
EventHandler.trigger(this._element, EVENT_HIDDEN)
|
|
257
|
+
})
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
_isAnimated() {
|
|
261
|
+
return this._element.classList.contains(CLASS_NAME_FADE)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
_triggerBackdropTransition() {
|
|
265
|
+
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)
|
|
266
|
+
if (hideEvent.defaultPrevented) {
|
|
267
|
+
return
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
|
|
271
|
+
const initialOverflowY = this._element.style.overflowY
|
|
272
|
+
// return if the following background transition hasn't yet completed
|
|
273
|
+
if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) {
|
|
274
|
+
return
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (!isModalOverflowing) {
|
|
278
|
+
this._element.style.overflowY = 'hidden'
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
this._element.classList.add(CLASS_NAME_STATIC)
|
|
282
|
+
this._queueCallback(() => {
|
|
283
|
+
this._element.classList.remove(CLASS_NAME_STATIC)
|
|
284
|
+
this._queueCallback(() => {
|
|
285
|
+
this._element.style.overflowY = initialOverflowY
|
|
286
|
+
}, this._dialog)
|
|
287
|
+
}, this._dialog)
|
|
288
|
+
|
|
289
|
+
this._element.focus()
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* The following methods are used to handle overflowing modals
|
|
294
|
+
*/
|
|
295
|
+
|
|
296
|
+
_adjustDialog() {
|
|
297
|
+
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
|
|
298
|
+
const scrollbarWidth = this._scrollBar.getWidth()
|
|
299
|
+
const isBodyOverflowing = scrollbarWidth > 0
|
|
300
|
+
|
|
301
|
+
if (isBodyOverflowing && !isModalOverflowing) {
|
|
302
|
+
const property = isRTL() ? 'paddingLeft' : 'paddingRight'
|
|
303
|
+
this._element.style[property] = `${scrollbarWidth}px`
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (!isBodyOverflowing && isModalOverflowing) {
|
|
307
|
+
const property = isRTL() ? 'paddingRight' : 'paddingLeft'
|
|
308
|
+
this._element.style[property] = `${scrollbarWidth}px`
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
_resetAdjustments() {
|
|
313
|
+
this._element.style.paddingLeft = ''
|
|
314
|
+
this._element.style.paddingRight = ''
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Static
|
|
318
|
+
static jQueryInterface(config, relatedTarget) {
|
|
319
|
+
return this.each(function () {
|
|
320
|
+
const data = Modal.getOrCreateInstance(this, config)
|
|
321
|
+
|
|
322
|
+
if (typeof config !== 'string') {
|
|
323
|
+
return
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (typeof data[config] === 'undefined') {
|
|
327
|
+
throw new TypeError(`No method named "${config}"`)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
data[config](relatedTarget)
|
|
331
|
+
})
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Data API implementation
|
|
337
|
+
*/
|
|
338
|
+
|
|
339
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
|
340
|
+
const target = SelectorEngine.getElementFromSelector(this)
|
|
341
|
+
|
|
342
|
+
if (['A', 'AREA'].includes(this.tagName)) {
|
|
343
|
+
event.preventDefault()
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
EventHandler.one(target, EVENT_SHOW, showEvent => {
|
|
347
|
+
if (showEvent.defaultPrevented) {
|
|
348
|
+
// only register focus restorer if modal will actually get shown
|
|
349
|
+
return
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
EventHandler.one(target, EVENT_HIDDEN, () => {
|
|
353
|
+
if (isVisible(this)) {
|
|
354
|
+
this.focus()
|
|
355
|
+
}
|
|
356
|
+
})
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
// avoid conflict when clicking modal toggler while another one is open
|
|
360
|
+
const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR)
|
|
361
|
+
if (alreadyOpen) {
|
|
362
|
+
Modal.getInstance(alreadyOpen).hide()
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const data = Modal.getOrCreateInstance(target)
|
|
366
|
+
|
|
367
|
+
data.toggle(this)
|
|
368
|
+
})
|
|
369
|
+
|
|
370
|
+
enableDismissTrigger(Modal)
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* jQuery
|
|
374
|
+
*/
|
|
375
|
+
|
|
376
|
+
defineJQueryPlugin(Modal)
|
|
377
|
+
|
|
378
|
+
export default Modal
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap offcanvas.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 SelectorEngine from './dom/selector-engine.js'
|
|
11
|
+
import Backdrop from './util/backdrop.js'
|
|
12
|
+
import { enableDismissTrigger } from './util/component-functions.js'
|
|
13
|
+
import FocusTrap from './util/focustrap.js'
|
|
14
|
+
import {
|
|
15
|
+
defineJQueryPlugin,
|
|
16
|
+
isDisabled,
|
|
17
|
+
isVisible
|
|
18
|
+
} from './util/index.js'
|
|
19
|
+
import ScrollBarHelper from './util/scrollbar.js'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Constants
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const NAME = 'offcanvas'
|
|
26
|
+
const DATA_KEY = 'bs.offcanvas'
|
|
27
|
+
const EVENT_KEY = `.${DATA_KEY}`
|
|
28
|
+
const DATA_API_KEY = '.data-api'
|
|
29
|
+
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
|
|
30
|
+
const ESCAPE_KEY = 'Escape'
|
|
31
|
+
|
|
32
|
+
const CLASS_NAME_SHOW = 'show'
|
|
33
|
+
const CLASS_NAME_SHOWING = 'showing'
|
|
34
|
+
const CLASS_NAME_HIDING = 'hiding'
|
|
35
|
+
const CLASS_NAME_BACKDROP = 'offcanvas-backdrop'
|
|
36
|
+
const OPEN_SELECTOR = '.offcanvas.show'
|
|
37
|
+
|
|
38
|
+
const EVENT_SHOW = `show${EVENT_KEY}`
|
|
39
|
+
const EVENT_SHOWN = `shown${EVENT_KEY}`
|
|
40
|
+
const EVENT_HIDE = `hide${EVENT_KEY}`
|
|
41
|
+
const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`
|
|
42
|
+
const EVENT_HIDDEN = `hidden${EVENT_KEY}`
|
|
43
|
+
const EVENT_RESIZE = `resize${EVENT_KEY}`
|
|
44
|
+
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
|
|
45
|
+
const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`
|
|
46
|
+
|
|
47
|
+
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="offcanvas"]'
|
|
48
|
+
|
|
49
|
+
const Default = {
|
|
50
|
+
backdrop: true,
|
|
51
|
+
keyboard: true,
|
|
52
|
+
scroll: false
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const DefaultType = {
|
|
56
|
+
backdrop: '(boolean|string)',
|
|
57
|
+
keyboard: 'boolean',
|
|
58
|
+
scroll: 'boolean'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Class definition
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
class Offcanvas extends BaseComponent {
|
|
66
|
+
constructor(element, config) {
|
|
67
|
+
super(element, config)
|
|
68
|
+
|
|
69
|
+
this._isShown = false
|
|
70
|
+
this._backdrop = this._initializeBackDrop()
|
|
71
|
+
this._focustrap = this._initializeFocusTrap()
|
|
72
|
+
this._addEventListeners()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Getters
|
|
76
|
+
static get Default() {
|
|
77
|
+
return Default
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static get DefaultType() {
|
|
81
|
+
return DefaultType
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static get NAME() {
|
|
85
|
+
return NAME
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Public
|
|
89
|
+
toggle(relatedTarget) {
|
|
90
|
+
return this._isShown ? this.hide() : this.show(relatedTarget)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
show(relatedTarget) {
|
|
94
|
+
if (this._isShown) {
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, { relatedTarget })
|
|
99
|
+
|
|
100
|
+
if (showEvent.defaultPrevented) {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this._isShown = true
|
|
105
|
+
this._backdrop.show()
|
|
106
|
+
|
|
107
|
+
if (!this._config.scroll) {
|
|
108
|
+
new ScrollBarHelper().hide()
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
this._element.setAttribute('aria-modal', true)
|
|
112
|
+
this._element.setAttribute('role', 'dialog')
|
|
113
|
+
this._element.classList.add(CLASS_NAME_SHOWING)
|
|
114
|
+
|
|
115
|
+
const completeCallBack = () => {
|
|
116
|
+
if (!this._config.scroll || this._config.backdrop) {
|
|
117
|
+
this._focustrap.activate()
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this._element.classList.add(CLASS_NAME_SHOW)
|
|
121
|
+
this._element.classList.remove(CLASS_NAME_SHOWING)
|
|
122
|
+
EventHandler.trigger(this._element, EVENT_SHOWN, { relatedTarget })
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
this._queueCallback(completeCallBack, this._element, true)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
hide() {
|
|
129
|
+
if (!this._isShown) {
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE)
|
|
134
|
+
|
|
135
|
+
if (hideEvent.defaultPrevented) {
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this._focustrap.deactivate()
|
|
140
|
+
this._element.blur()
|
|
141
|
+
this._isShown = false
|
|
142
|
+
this._element.classList.add(CLASS_NAME_HIDING)
|
|
143
|
+
this._backdrop.hide()
|
|
144
|
+
|
|
145
|
+
const completeCallback = () => {
|
|
146
|
+
this._element.classList.remove(CLASS_NAME_SHOW, CLASS_NAME_HIDING)
|
|
147
|
+
this._element.removeAttribute('aria-modal')
|
|
148
|
+
this._element.removeAttribute('role')
|
|
149
|
+
|
|
150
|
+
if (!this._config.scroll) {
|
|
151
|
+
new ScrollBarHelper().reset()
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
EventHandler.trigger(this._element, EVENT_HIDDEN)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
this._queueCallback(completeCallback, this._element, true)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
dispose() {
|
|
161
|
+
this._backdrop.dispose()
|
|
162
|
+
this._focustrap.deactivate()
|
|
163
|
+
super.dispose()
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Private
|
|
167
|
+
_initializeBackDrop() {
|
|
168
|
+
const clickCallback = () => {
|
|
169
|
+
if (this._config.backdrop === 'static') {
|
|
170
|
+
EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)
|
|
171
|
+
return
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
this.hide()
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// 'static' option will be translated to true, and booleans will keep their value
|
|
178
|
+
const isVisible = Boolean(this._config.backdrop)
|
|
179
|
+
|
|
180
|
+
return new Backdrop({
|
|
181
|
+
className: CLASS_NAME_BACKDROP,
|
|
182
|
+
isVisible,
|
|
183
|
+
isAnimated: true,
|
|
184
|
+
rootElement: this._element.parentNode,
|
|
185
|
+
clickCallback: isVisible ? clickCallback : null
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
_initializeFocusTrap() {
|
|
190
|
+
return new FocusTrap({
|
|
191
|
+
trapElement: this._element
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
_addEventListeners() {
|
|
196
|
+
EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
|
|
197
|
+
if (event.key !== ESCAPE_KEY) {
|
|
198
|
+
return
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (this._config.keyboard) {
|
|
202
|
+
this.hide()
|
|
203
|
+
return
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Static
|
|
211
|
+
static jQueryInterface(config) {
|
|
212
|
+
return this.each(function () {
|
|
213
|
+
const data = Offcanvas.getOrCreateInstance(this, config)
|
|
214
|
+
|
|
215
|
+
if (typeof config !== 'string') {
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
|
|
220
|
+
throw new TypeError(`No method named "${config}"`)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
data[config](this)
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Data API implementation
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
|
233
|
+
const target = SelectorEngine.getElementFromSelector(this)
|
|
234
|
+
|
|
235
|
+
if (['A', 'AREA'].includes(this.tagName)) {
|
|
236
|
+
event.preventDefault()
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (isDisabled(this)) {
|
|
240
|
+
return
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
EventHandler.one(target, EVENT_HIDDEN, () => {
|
|
244
|
+
// focus on trigger when it is closed
|
|
245
|
+
if (isVisible(this)) {
|
|
246
|
+
this.focus()
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
// avoid conflict when clicking a toggler of an offcanvas, while another is open
|
|
251
|
+
const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR)
|
|
252
|
+
if (alreadyOpen && alreadyOpen !== target) {
|
|
253
|
+
Offcanvas.getInstance(alreadyOpen).hide()
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const data = Offcanvas.getOrCreateInstance(target)
|
|
257
|
+
data.toggle(this)
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
|
|
261
|
+
for (const selector of SelectorEngine.find(OPEN_SELECTOR)) {
|
|
262
|
+
Offcanvas.getOrCreateInstance(selector).show()
|
|
263
|
+
}
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
EventHandler.on(window, EVENT_RESIZE, () => {
|
|
267
|
+
for (const element of SelectorEngine.find('[aria-modal][class*=show][class*=offcanvas-]')) {
|
|
268
|
+
if (getComputedStyle(element).position !== 'fixed') {
|
|
269
|
+
Offcanvas.getOrCreateInstance(element).hide()
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
enableDismissTrigger(Offcanvas)
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* jQuery
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
defineJQueryPlugin(Offcanvas)
|
|
281
|
+
|
|
282
|
+
export default Offcanvas
|