administrate-bootstrap-theme 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -4
  3. data/app/assets/javascripts/administrate-bootstrap-theme/bootstrap/bootstrap.bundle.js +6714 -0
  4. data/app/assets/javascripts/administrate-bootstrap-theme/flatpickr/flatpickr.js +2673 -0
  5. data/app/assets/javascripts/administrate-bootstrap-theme/theme.js +21 -1
  6. data/app/assets/stylesheets/administrate-bootstrap-theme/_base.scss +5 -1
  7. data/app/assets/stylesheets/administrate-bootstrap-theme/_variables.scss +4 -1
  8. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_accordion.scss +0 -0
  9. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_alert.scss +0 -0
  10. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_badge.scss +0 -0
  11. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_breadcrumb.scss +0 -0
  12. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_button-group.scss +0 -0
  13. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_buttons.scss +0 -0
  14. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_card.scss +0 -0
  15. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_carousel.scss +0 -0
  16. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_close.scss +0 -0
  17. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_containers.scss +0 -0
  18. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_dropdown.scss +0 -0
  19. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_forms.scss +0 -0
  20. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_functions.scss +0 -0
  21. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_grid.scss +0 -0
  22. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_helpers.scss +0 -0
  23. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_images.scss +0 -0
  24. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_list-group.scss +0 -0
  25. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_mixins.scss +0 -0
  26. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_modal.scss +0 -0
  27. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_nav.scss +0 -0
  28. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_navbar.scss +0 -0
  29. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_offcanvas.scss +0 -0
  30. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_pagination.scss +0 -0
  31. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_popover.scss +0 -0
  32. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_progress.scss +0 -0
  33. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_reboot.scss +0 -0
  34. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_root.scss +0 -0
  35. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_spinners.scss +0 -0
  36. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_tables.scss +0 -0
  37. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_toasts.scss +0 -0
  38. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_tooltip.scss +0 -0
  39. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_transitions.scss +0 -0
  40. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_type.scss +0 -0
  41. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_utilities.scss +0 -0
  42. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_variables.scss +0 -0
  43. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap-grid.scss +0 -0
  44. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap-reboot.scss +0 -0
  45. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap-utilities.scss +0 -0
  46. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap.scss +0 -0
  47. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_floating-labels.scss +0 -0
  48. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-check.scss +0 -0
  49. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-control.scss +0 -0
  50. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-range.scss +0 -0
  51. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-select.scss +0 -0
  52. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-text.scss +0 -0
  53. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_input-group.scss +0 -0
  54. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_labels.scss +0 -0
  55. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_validation.scss +0 -0
  56. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_clearfix.scss +0 -0
  57. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_colored-links.scss +0 -0
  58. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_position.scss +0 -0
  59. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_ratio.scss +0 -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/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_alert.scss +0 -0
  64. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_border-radius.scss +0 -0
  65. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_box-shadow.scss +0 -0
  66. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_breakpoints.scss +0 -0
  67. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_buttons.scss +0 -0
  68. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_caret.scss +0 -0
  69. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_clearfix.scss +0 -0
  70. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_container.scss +0 -0
  71. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_deprecate.scss +0 -0
  72. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_forms.scss +0 -0
  73. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_gradients.scss +0 -0
  74. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_grid.scss +0 -0
  75. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_image.scss +0 -0
  76. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_list-group.scss +0 -0
  77. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_lists.scss +0 -0
  78. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_pagination.scss +0 -0
  79. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_reset-text.scss +0 -0
  80. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_resize.scss +0 -0
  81. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_table-variants.scss +0 -0
  82. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_text-truncate.scss +0 -0
  83. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_transition.scss +0 -0
  84. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_utilities.scss +0 -0
  85. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_visually-hidden.scss +0 -0
  86. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/utilities/_api.scss +0 -0
  87. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/vendor/_rfs.scss +0 -0
  88. data/app/assets/stylesheets/administrate-bootstrap-theme/components/_navigation.scss +1 -5
  89. data/app/assets/stylesheets/administrate-bootstrap-theme/flatpickr/flatpickr.css +791 -0
  90. data/app/assets/stylesheets/administrate-bootstrap-theme/theme.scss +11 -1
  91. data/lib/administrate-bootstrap-theme/engine.rb +0 -2
  92. data/lib/administrate-bootstrap-theme/version.rb +1 -1
  93. metadata +88 -105
  94. data/node_modules/bootstrap/js/src/alert.js +0 -141
  95. data/node_modules/bootstrap/js/src/base-component.js +0 -46
  96. data/node_modules/bootstrap/js/src/button.js +0 -95
  97. data/node_modules/bootstrap/js/src/carousel.js +0 -624
  98. data/node_modules/bootstrap/js/src/collapse.js +0 -410
  99. data/node_modules/bootstrap/js/src/dom/data.js +0 -57
  100. data/node_modules/bootstrap/js/src/dom/event-handler.js +0 -331
  101. data/node_modules/bootstrap/js/src/dom/manipulator.js +0 -80
  102. data/node_modules/bootstrap/js/src/dom/selector-engine.js +0 -75
  103. data/node_modules/bootstrap/js/src/dropdown.js +0 -543
  104. data/node_modules/bootstrap/js/src/modal.js +0 -582
  105. data/node_modules/bootstrap/js/src/offcanvas.js +0 -279
  106. data/node_modules/bootstrap/js/src/popover.js +0 -171
  107. data/node_modules/bootstrap/js/src/scrollspy.js +0 -319
  108. data/node_modules/bootstrap/js/src/tab.js +0 -220
  109. data/node_modules/bootstrap/js/src/toast.js +0 -219
  110. data/node_modules/bootstrap/js/src/tooltip.js +0 -802
  111. data/node_modules/bootstrap/js/src/util/index.js +0 -253
  112. data/node_modules/bootstrap/js/src/util/sanitizer.js +0 -127
  113. data/node_modules/bootstrap/js/src/util/scrollbar.js +0 -70
@@ -1,582 +0,0 @@
1
- /**
2
- * --------------------------------------------------------------------------
3
- * Bootstrap (v5.0.0-beta3): modal.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
- isVisible,
14
- isRTL,
15
- reflow,
16
- typeCheckConfig
17
- } from './util/index'
18
- import Data from './dom/data'
19
- import EventHandler from './dom/event-handler'
20
- import Manipulator from './dom/manipulator'
21
- import SelectorEngine from './dom/selector-engine'
22
- import BaseComponent from './base-component'
23
-
24
- /**
25
- * ------------------------------------------------------------------------
26
- * Constants
27
- * ------------------------------------------------------------------------
28
- */
29
-
30
- const NAME = 'modal'
31
- const DATA_KEY = 'bs.modal'
32
- const EVENT_KEY = `.${DATA_KEY}`
33
- const DATA_API_KEY = '.data-api'
34
- const ESCAPE_KEY = 'Escape'
35
-
36
- const Default = {
37
- backdrop: true,
38
- keyboard: true,
39
- focus: true
40
- }
41
-
42
- const DefaultType = {
43
- backdrop: '(boolean|string)',
44
- keyboard: 'boolean',
45
- focus: 'boolean'
46
- }
47
-
48
- const EVENT_HIDE = `hide${EVENT_KEY}`
49
- const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`
50
- const EVENT_HIDDEN = `hidden${EVENT_KEY}`
51
- const EVENT_SHOW = `show${EVENT_KEY}`
52
- const EVENT_SHOWN = `shown${EVENT_KEY}`
53
- const EVENT_FOCUSIN = `focusin${EVENT_KEY}`
54
- const EVENT_RESIZE = `resize${EVENT_KEY}`
55
- const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`
56
- const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`
57
- const EVENT_MOUSEUP_DISMISS = `mouseup.dismiss${EVENT_KEY}`
58
- const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY}`
59
- const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
60
-
61
- const CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure'
62
- const CLASS_NAME_BACKDROP = 'modal-backdrop'
63
- const CLASS_NAME_OPEN = 'modal-open'
64
- const CLASS_NAME_FADE = 'fade'
65
- const CLASS_NAME_SHOW = 'show'
66
- const CLASS_NAME_STATIC = 'modal-static'
67
-
68
- const SELECTOR_DIALOG = '.modal-dialog'
69
- const SELECTOR_MODAL_BODY = '.modal-body'
70
- const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="modal"]'
71
- const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="modal"]'
72
- const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'
73
- const SELECTOR_STICKY_CONTENT = '.sticky-top'
74
-
75
- /**
76
- * ------------------------------------------------------------------------
77
- * Class Definition
78
- * ------------------------------------------------------------------------
79
- */
80
-
81
- class Modal extends BaseComponent {
82
- constructor(element, config) {
83
- super(element)
84
-
85
- this._config = this._getConfig(config)
86
- this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element)
87
- this._backdrop = null
88
- this._isShown = false
89
- this._isBodyOverflowing = false
90
- this._ignoreBackdropClick = false
91
- this._isTransitioning = false
92
- this._scrollbarWidth = 0
93
- }
94
-
95
- // Getters
96
-
97
- static get Default() {
98
- return Default
99
- }
100
-
101
- static get DATA_KEY() {
102
- return DATA_KEY
103
- }
104
-
105
- // Public
106
-
107
- toggle(relatedTarget) {
108
- return this._isShown ? this.hide() : this.show(relatedTarget)
109
- }
110
-
111
- show(relatedTarget) {
112
- if (this._isShown || this._isTransitioning) {
113
- return
114
- }
115
-
116
- if (this._isAnimated()) {
117
- this._isTransitioning = true
118
- }
119
-
120
- const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, {
121
- relatedTarget
122
- })
123
-
124
- if (this._isShown || showEvent.defaultPrevented) {
125
- return
126
- }
127
-
128
- this._isShown = true
129
-
130
- this._checkScrollbar()
131
- this._setScrollbar()
132
-
133
- this._adjustDialog()
134
-
135
- this._setEscapeEvent()
136
- this._setResizeEvent()
137
-
138
- EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, event => this.hide(event))
139
-
140
- EventHandler.on(this._dialog, EVENT_MOUSEDOWN_DISMISS, () => {
141
- EventHandler.one(this._element, EVENT_MOUSEUP_DISMISS, event => {
142
- if (event.target === this._element) {
143
- this._ignoreBackdropClick = true
144
- }
145
- })
146
- })
147
-
148
- this._showBackdrop(() => this._showElement(relatedTarget))
149
- }
150
-
151
- hide(event) {
152
- if (event) {
153
- event.preventDefault()
154
- }
155
-
156
- if (!this._isShown || this._isTransitioning) {
157
- return
158
- }
159
-
160
- const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE)
161
-
162
- if (hideEvent.defaultPrevented) {
163
- return
164
- }
165
-
166
- this._isShown = false
167
- const isAnimated = this._isAnimated()
168
-
169
- if (isAnimated) {
170
- this._isTransitioning = true
171
- }
172
-
173
- this._setEscapeEvent()
174
- this._setResizeEvent()
175
-
176
- EventHandler.off(document, EVENT_FOCUSIN)
177
-
178
- this._element.classList.remove(CLASS_NAME_SHOW)
179
-
180
- EventHandler.off(this._element, EVENT_CLICK_DISMISS)
181
- EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS)
182
-
183
- if (isAnimated) {
184
- const transitionDuration = getTransitionDurationFromElement(this._element)
185
-
186
- EventHandler.one(this._element, 'transitionend', event => this._hideModal(event))
187
- emulateTransitionEnd(this._element, transitionDuration)
188
- } else {
189
- this._hideModal()
190
- }
191
- }
192
-
193
- dispose() {
194
- [window, this._element, this._dialog]
195
- .forEach(htmlElement => EventHandler.off(htmlElement, EVENT_KEY))
196
-
197
- super.dispose()
198
-
199
- /**
200
- * `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
201
- * Do not move `document` in `htmlElements` array
202
- * It will remove `EVENT_CLICK_DATA_API` event that should remain
203
- */
204
- EventHandler.off(document, EVENT_FOCUSIN)
205
-
206
- this._config = null
207
- this._dialog = null
208
- this._backdrop = null
209
- this._isShown = null
210
- this._isBodyOverflowing = null
211
- this._ignoreBackdropClick = null
212
- this._isTransitioning = null
213
- this._scrollbarWidth = null
214
- }
215
-
216
- handleUpdate() {
217
- this._adjustDialog()
218
- }
219
-
220
- // Private
221
-
222
- _getConfig(config) {
223
- config = {
224
- ...Default,
225
- ...config
226
- }
227
- typeCheckConfig(NAME, config, DefaultType)
228
- return config
229
- }
230
-
231
- _showElement(relatedTarget) {
232
- const isAnimated = this._isAnimated()
233
- const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog)
234
-
235
- if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
236
- // Don't move modal's DOM position
237
- document.body.appendChild(this._element)
238
- }
239
-
240
- this._element.style.display = 'block'
241
- this._element.removeAttribute('aria-hidden')
242
- this._element.setAttribute('aria-modal', true)
243
- this._element.setAttribute('role', 'dialog')
244
- this._element.scrollTop = 0
245
-
246
- if (modalBody) {
247
- modalBody.scrollTop = 0
248
- }
249
-
250
- if (isAnimated) {
251
- reflow(this._element)
252
- }
253
-
254
- this._element.classList.add(CLASS_NAME_SHOW)
255
-
256
- if (this._config.focus) {
257
- this._enforceFocus()
258
- }
259
-
260
- const transitionComplete = () => {
261
- if (this._config.focus) {
262
- this._element.focus()
263
- }
264
-
265
- this._isTransitioning = false
266
- EventHandler.trigger(this._element, EVENT_SHOWN, {
267
- relatedTarget
268
- })
269
- }
270
-
271
- if (isAnimated) {
272
- const transitionDuration = getTransitionDurationFromElement(this._dialog)
273
-
274
- EventHandler.one(this._dialog, 'transitionend', transitionComplete)
275
- emulateTransitionEnd(this._dialog, transitionDuration)
276
- } else {
277
- transitionComplete()
278
- }
279
- }
280
-
281
- _enforceFocus() {
282
- EventHandler.off(document, EVENT_FOCUSIN) // guard against infinite focus loop
283
- EventHandler.on(document, EVENT_FOCUSIN, event => {
284
- if (document !== event.target &&
285
- this._element !== event.target &&
286
- !this._element.contains(event.target)) {
287
- this._element.focus()
288
- }
289
- })
290
- }
291
-
292
- _setEscapeEvent() {
293
- if (this._isShown) {
294
- EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
295
- if (this._config.keyboard && event.key === ESCAPE_KEY) {
296
- event.preventDefault()
297
- this.hide()
298
- } else if (!this._config.keyboard && event.key === ESCAPE_KEY) {
299
- this._triggerBackdropTransition()
300
- }
301
- })
302
- } else {
303
- EventHandler.off(this._element, EVENT_KEYDOWN_DISMISS)
304
- }
305
- }
306
-
307
- _setResizeEvent() {
308
- if (this._isShown) {
309
- EventHandler.on(window, EVENT_RESIZE, () => this._adjustDialog())
310
- } else {
311
- EventHandler.off(window, EVENT_RESIZE)
312
- }
313
- }
314
-
315
- _hideModal() {
316
- this._element.style.display = 'none'
317
- this._element.setAttribute('aria-hidden', true)
318
- this._element.removeAttribute('aria-modal')
319
- this._element.removeAttribute('role')
320
- this._isTransitioning = false
321
- this._showBackdrop(() => {
322
- document.body.classList.remove(CLASS_NAME_OPEN)
323
- this._resetAdjustments()
324
- this._resetScrollbar()
325
- EventHandler.trigger(this._element, EVENT_HIDDEN)
326
- })
327
- }
328
-
329
- _removeBackdrop() {
330
- this._backdrop.parentNode.removeChild(this._backdrop)
331
- this._backdrop = null
332
- }
333
-
334
- _showBackdrop(callback) {
335
- const isAnimated = this._isAnimated()
336
- if (this._isShown && this._config.backdrop) {
337
- this._backdrop = document.createElement('div')
338
- this._backdrop.className = CLASS_NAME_BACKDROP
339
-
340
- if (isAnimated) {
341
- this._backdrop.classList.add(CLASS_NAME_FADE)
342
- }
343
-
344
- document.body.appendChild(this._backdrop)
345
-
346
- EventHandler.on(this._element, EVENT_CLICK_DISMISS, event => {
347
- if (this._ignoreBackdropClick) {
348
- this._ignoreBackdropClick = false
349
- return
350
- }
351
-
352
- if (event.target !== event.currentTarget) {
353
- return
354
- }
355
-
356
- if (this._config.backdrop === 'static') {
357
- this._triggerBackdropTransition()
358
- } else {
359
- this.hide()
360
- }
361
- })
362
-
363
- if (isAnimated) {
364
- reflow(this._backdrop)
365
- }
366
-
367
- this._backdrop.classList.add(CLASS_NAME_SHOW)
368
-
369
- if (!isAnimated) {
370
- callback()
371
- return
372
- }
373
-
374
- const backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop)
375
-
376
- EventHandler.one(this._backdrop, 'transitionend', callback)
377
- emulateTransitionEnd(this._backdrop, backdropTransitionDuration)
378
- } else if (!this._isShown && this._backdrop) {
379
- this._backdrop.classList.remove(CLASS_NAME_SHOW)
380
-
381
- const callbackRemove = () => {
382
- this._removeBackdrop()
383
- callback()
384
- }
385
-
386
- if (isAnimated) {
387
- const backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop)
388
- EventHandler.one(this._backdrop, 'transitionend', callbackRemove)
389
- emulateTransitionEnd(this._backdrop, backdropTransitionDuration)
390
- } else {
391
- callbackRemove()
392
- }
393
- } else {
394
- callback()
395
- }
396
- }
397
-
398
- _isAnimated() {
399
- return this._element.classList.contains(CLASS_NAME_FADE)
400
- }
401
-
402
- _triggerBackdropTransition() {
403
- const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)
404
- if (hideEvent.defaultPrevented) {
405
- return
406
- }
407
-
408
- const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
409
-
410
- if (!isModalOverflowing) {
411
- this._element.style.overflowY = 'hidden'
412
- }
413
-
414
- this._element.classList.add(CLASS_NAME_STATIC)
415
- const modalTransitionDuration = getTransitionDurationFromElement(this._dialog)
416
- EventHandler.off(this._element, 'transitionend')
417
- EventHandler.one(this._element, 'transitionend', () => {
418
- this._element.classList.remove(CLASS_NAME_STATIC)
419
- if (!isModalOverflowing) {
420
- EventHandler.one(this._element, 'transitionend', () => {
421
- this._element.style.overflowY = ''
422
- })
423
- emulateTransitionEnd(this._element, modalTransitionDuration)
424
- }
425
- })
426
- emulateTransitionEnd(this._element, modalTransitionDuration)
427
- this._element.focus()
428
- }
429
-
430
- // ----------------------------------------------------------------------
431
- // the following methods are used to handle overflowing modals
432
- // ----------------------------------------------------------------------
433
-
434
- _adjustDialog() {
435
- const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
436
-
437
- if ((!this._isBodyOverflowing && isModalOverflowing && !isRTL()) || (this._isBodyOverflowing && !isModalOverflowing && isRTL())) {
438
- this._element.style.paddingLeft = `${this._scrollbarWidth}px`
439
- }
440
-
441
- if ((this._isBodyOverflowing && !isModalOverflowing && !isRTL()) || (!this._isBodyOverflowing && isModalOverflowing && isRTL())) {
442
- this._element.style.paddingRight = `${this._scrollbarWidth}px`
443
- }
444
- }
445
-
446
- _resetAdjustments() {
447
- this._element.style.paddingLeft = ''
448
- this._element.style.paddingRight = ''
449
- }
450
-
451
- _checkScrollbar() {
452
- const rect = document.body.getBoundingClientRect()
453
- this._isBodyOverflowing = Math.round(rect.left + rect.right) < window.innerWidth
454
- this._scrollbarWidth = this._getScrollbarWidth()
455
- }
456
-
457
- _setScrollbar() {
458
- if (this._isBodyOverflowing) {
459
- this._setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + this._scrollbarWidth)
460
- this._setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - this._scrollbarWidth)
461
- this._setElementAttributes('body', 'paddingRight', calculatedValue => calculatedValue + this._scrollbarWidth)
462
- }
463
-
464
- document.body.classList.add(CLASS_NAME_OPEN)
465
- }
466
-
467
- _setElementAttributes(selector, styleProp, callback) {
468
- SelectorEngine.find(selector)
469
- .forEach(element => {
470
- if (element !== document.body && window.innerWidth > element.clientWidth + this._scrollbarWidth) {
471
- return
472
- }
473
-
474
- const actualValue = element.style[styleProp]
475
- const calculatedValue = window.getComputedStyle(element)[styleProp]
476
- Manipulator.setDataAttribute(element, styleProp, actualValue)
477
- element.style[styleProp] = callback(Number.parseFloat(calculatedValue)) + 'px'
478
- })
479
- }
480
-
481
- _resetScrollbar() {
482
- this._resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight')
483
- this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight')
484
- this._resetElementAttributes('body', 'paddingRight')
485
- }
486
-
487
- _resetElementAttributes(selector, styleProp) {
488
- SelectorEngine.find(selector).forEach(element => {
489
- const value = Manipulator.getDataAttribute(element, styleProp)
490
- if (typeof value === 'undefined' && element === document.body) {
491
- element.style[styleProp] = ''
492
- } else {
493
- Manipulator.removeDataAttribute(element, styleProp)
494
- element.style[styleProp] = value
495
- }
496
- })
497
- }
498
-
499
- _getScrollbarWidth() { // thx d.walsh
500
- const scrollDiv = document.createElement('div')
501
- scrollDiv.className = CLASS_NAME_SCROLLBAR_MEASURER
502
- document.body.appendChild(scrollDiv)
503
- const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth
504
- document.body.removeChild(scrollDiv)
505
- return scrollbarWidth
506
- }
507
-
508
- // Static
509
-
510
- static jQueryInterface(config, relatedTarget) {
511
- return this.each(function () {
512
- let data = Data.get(this, DATA_KEY)
513
- const _config = {
514
- ...Default,
515
- ...Manipulator.getDataAttributes(this),
516
- ...(typeof config === 'object' && config ? config : {})
517
- }
518
-
519
- if (!data) {
520
- data = new Modal(this, _config)
521
- }
522
-
523
- if (typeof config === 'string') {
524
- if (typeof data[config] === 'undefined') {
525
- throw new TypeError(`No method named "${config}"`)
526
- }
527
-
528
- data[config](relatedTarget)
529
- }
530
- })
531
- }
532
- }
533
-
534
- /**
535
- * ------------------------------------------------------------------------
536
- * Data Api implementation
537
- * ------------------------------------------------------------------------
538
- */
539
-
540
- EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
541
- const target = getElementFromSelector(this)
542
-
543
- if (this.tagName === 'A' || this.tagName === 'AREA') {
544
- event.preventDefault()
545
- }
546
-
547
- EventHandler.one(target, EVENT_SHOW, showEvent => {
548
- if (showEvent.defaultPrevented) {
549
- // only register focus restorer if modal will actually get shown
550
- return
551
- }
552
-
553
- EventHandler.one(target, EVENT_HIDDEN, () => {
554
- if (isVisible(this)) {
555
- this.focus()
556
- }
557
- })
558
- })
559
-
560
- let data = Data.get(target, DATA_KEY)
561
- if (!data) {
562
- const config = {
563
- ...Manipulator.getDataAttributes(target),
564
- ...Manipulator.getDataAttributes(this)
565
- }
566
-
567
- data = new Modal(target, config)
568
- }
569
-
570
- data.toggle(this)
571
- })
572
-
573
- /**
574
- * ------------------------------------------------------------------------
575
- * jQuery
576
- * ------------------------------------------------------------------------
577
- * add .Modal to jQuery only if jQuery is present
578
- */
579
-
580
- defineJQueryPlugin(NAME, Modal)
581
-
582
- export default Modal