administrate-bootstrap-theme 0.1.0 → 0.1.9
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 +4 -4
- data/README.md +25 -11
- data/Rakefile +10 -14
- data/app/assets/config/administrate-bootstrap-theme_manifest.js +1 -0
- data/app/assets/javascripts/administrate-bootstrap-theme/theme.js +2 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/_base.scss +17 -1
- data/app/assets/stylesheets/administrate-bootstrap-theme/components/_content_body.scss +17 -3
- data/app/assets/stylesheets/administrate-bootstrap-theme/components/_form.scss +52 -16
- data/app/assets/stylesheets/administrate-bootstrap-theme/theme.scss +12 -0
- data/lib/administrate-bootstrap-theme/engine.rb +2 -0
- data/lib/administrate-bootstrap-theme/version.rb +1 -1
- data/node_modules/bootstrap/js/src/alert.js +141 -0
- data/node_modules/bootstrap/js/src/base-component.js +46 -0
- data/node_modules/bootstrap/js/src/button.js +95 -0
- data/node_modules/bootstrap/js/src/carousel.js +624 -0
- data/node_modules/bootstrap/js/src/collapse.js +410 -0
- data/node_modules/bootstrap/js/src/dom/data.js +57 -0
- data/node_modules/bootstrap/js/src/dom/event-handler.js +331 -0
- data/node_modules/bootstrap/js/src/dom/manipulator.js +80 -0
- data/node_modules/bootstrap/js/src/dom/selector-engine.js +75 -0
- data/node_modules/bootstrap/js/src/dropdown.js +543 -0
- data/node_modules/bootstrap/js/src/modal.js +582 -0
- data/node_modules/bootstrap/js/src/offcanvas.js +279 -0
- data/node_modules/bootstrap/js/src/popover.js +171 -0
- data/node_modules/bootstrap/js/src/scrollspy.js +319 -0
- data/node_modules/bootstrap/js/src/tab.js +220 -0
- data/node_modules/bootstrap/js/src/toast.js +219 -0
- data/node_modules/bootstrap/js/src/tooltip.js +802 -0
- data/node_modules/bootstrap/js/src/util/index.js +253 -0
- data/node_modules/bootstrap/js/src/util/sanitizer.js +127 -0
- data/node_modules/bootstrap/js/src/util/scrollbar.js +70 -0
- data/node_modules/bootstrap/scss/_accordion.scss +116 -0
- data/node_modules/bootstrap/scss/_alert.scss +57 -0
- data/node_modules/bootstrap/scss/_badge.scss +29 -0
- data/node_modules/bootstrap/scss/_breadcrumb.scss +28 -0
- data/node_modules/bootstrap/scss/_button-group.scss +139 -0
- data/node_modules/bootstrap/scss/_buttons.scss +111 -0
- data/node_modules/bootstrap/scss/_card.scss +215 -0
- data/node_modules/bootstrap/scss/_carousel.scss +229 -0
- data/node_modules/bootstrap/scss/_close.scss +40 -0
- data/node_modules/bootstrap/scss/_containers.scss +41 -0
- data/node_modules/bootstrap/scss/_dropdown.scss +246 -0
- data/node_modules/bootstrap/scss/_forms.scss +9 -0
- data/node_modules/bootstrap/scss/_functions.scss +205 -0
- data/node_modules/bootstrap/scss/_grid.scss +22 -0
- data/node_modules/bootstrap/scss/_helpers.scss +7 -0
- data/node_modules/bootstrap/scss/_images.scss +42 -0
- data/node_modules/bootstrap/scss/_list-group.scss +174 -0
- data/node_modules/bootstrap/scss/_mixins.scss +41 -0
- data/node_modules/bootstrap/scss/_modal.scss +237 -0
- data/node_modules/bootstrap/scss/_nav.scss +139 -0
- data/node_modules/bootstrap/scss/_navbar.scss +306 -0
- data/node_modules/bootstrap/scss/_offcanvas.scss +77 -0
- data/node_modules/bootstrap/scss/_pagination.scss +64 -0
- data/node_modules/bootstrap/scss/_popover.scss +158 -0
- data/node_modules/bootstrap/scss/_progress.scss +48 -0
- data/node_modules/bootstrap/scss/_reboot.scss +621 -0
- data/node_modules/bootstrap/scss/_root.scss +16 -0
- data/node_modules/bootstrap/scss/_spinners.scss +69 -0
- data/node_modules/bootstrap/scss/_tables.scss +150 -0
- data/node_modules/bootstrap/scss/_toasts.scss +51 -0
- data/node_modules/bootstrap/scss/_tooltip.scss +115 -0
- data/node_modules/bootstrap/scss/_transitions.scss +21 -0
- data/node_modules/bootstrap/scss/_type.scss +104 -0
- data/node_modules/bootstrap/scss/_utilities.scss +594 -0
- data/node_modules/bootstrap/scss/_variables.scss +1464 -0
- data/node_modules/bootstrap/scss/bootstrap-grid.scss +65 -0
- data/node_modules/bootstrap/scss/bootstrap-reboot.scss +15 -0
- data/node_modules/bootstrap/scss/bootstrap-utilities.scss +18 -0
- data/node_modules/bootstrap/scss/bootstrap.scss +52 -0
- data/node_modules/bootstrap/scss/forms/_floating-labels.scss +61 -0
- data/node_modules/bootstrap/scss/forms/_form-check.scss +152 -0
- data/node_modules/bootstrap/scss/forms/_form-control.scss +219 -0
- data/node_modules/bootstrap/scss/forms/_form-range.scss +91 -0
- data/node_modules/bootstrap/scss/forms/_form-select.scss +67 -0
- data/node_modules/bootstrap/scss/forms/_form-text.scss +11 -0
- data/node_modules/bootstrap/scss/forms/_input-group.scss +121 -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/_colored-links.scss +12 -0
- data/node_modules/bootstrap/scss/helpers/_position.scss +30 -0
- data/node_modules/bootstrap/scss/helpers/_ratio.scss +26 -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/mixins/_alert.scss +11 -0
- data/node_modules/bootstrap/scss/mixins/_border-radius.scss +78 -0
- data/node_modules/bootstrap/scss/mixins/_box-shadow.scss +18 -0
- data/node_modules/bootstrap/scss/mixins/_breakpoints.scss +127 -0
- data/node_modules/bootstrap/scss/mixins/_buttons.scss +133 -0
- data/node_modules/bootstrap/scss/mixins/_caret.scss +64 -0
- data/node_modules/bootstrap/scss/mixins/_clearfix.scss +9 -0
- data/node_modules/bootstrap/scss/mixins/_container.scss +9 -0
- data/node_modules/bootstrap/scss/mixins/_deprecate.scss +10 -0
- data/node_modules/bootstrap/scss/mixins/_forms.scss +134 -0
- data/node_modules/bootstrap/scss/mixins/_gradients.scss +47 -0
- data/node_modules/bootstrap/scss/mixins/_grid.scss +120 -0
- data/node_modules/bootstrap/scss/mixins/_image.scss +16 -0
- data/node_modules/bootstrap/scss/mixins/_list-group.scss +24 -0
- data/node_modules/bootstrap/scss/mixins/_lists.scss +7 -0
- data/node_modules/bootstrap/scss/mixins/_pagination.scss +31 -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 +21 -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 +68 -0
- data/node_modules/bootstrap/scss/mixins/_visually-hidden.scss +29 -0
- data/node_modules/bootstrap/scss/utilities/_api.scss +47 -0
- data/node_modules/bootstrap/scss/vendor/_rfs.scss +312 -0
- metadata +106 -19
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap (v5.0.0-beta3): offcanvas.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
defineJQueryPlugin,
|
|
10
|
+
getElementFromSelector,
|
|
11
|
+
getSelectorFromElement,
|
|
12
|
+
getTransitionDurationFromElement,
|
|
13
|
+
isDisabled,
|
|
14
|
+
isVisible,
|
|
15
|
+
typeCheckConfig
|
|
16
|
+
} from './util/index'
|
|
17
|
+
import { hide as scrollBarHide, reset as scrollBarReset } from './util/scrollbar'
|
|
18
|
+
import Data from './dom/data'
|
|
19
|
+
import EventHandler from './dom/event-handler'
|
|
20
|
+
import BaseComponent from './base-component'
|
|
21
|
+
import SelectorEngine from './dom/selector-engine'
|
|
22
|
+
import Manipulator from './dom/manipulator'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* ------------------------------------------------------------------------
|
|
26
|
+
* Constants
|
|
27
|
+
* ------------------------------------------------------------------------
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
const NAME = 'offcanvas'
|
|
31
|
+
const DATA_KEY = 'bs.offcanvas'
|
|
32
|
+
const EVENT_KEY = `.${DATA_KEY}`
|
|
33
|
+
const DATA_API_KEY = '.data-api'
|
|
34
|
+
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
|
|
35
|
+
const ESCAPE_KEY = 'Escape'
|
|
36
|
+
|
|
37
|
+
const Default = {
|
|
38
|
+
backdrop: true,
|
|
39
|
+
keyboard: true,
|
|
40
|
+
scroll: false
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const DefaultType = {
|
|
44
|
+
backdrop: 'boolean',
|
|
45
|
+
keyboard: 'boolean',
|
|
46
|
+
scroll: 'boolean'
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const CLASS_NAME_BACKDROP_BODY = 'offcanvas-backdrop'
|
|
50
|
+
const CLASS_NAME_SHOW = 'show'
|
|
51
|
+
const CLASS_NAME_TOGGLING = 'offcanvas-toggling'
|
|
52
|
+
const OPEN_SELECTOR = '.offcanvas.show'
|
|
53
|
+
const ACTIVE_SELECTOR = `${OPEN_SELECTOR}, .${CLASS_NAME_TOGGLING}`
|
|
54
|
+
|
|
55
|
+
const EVENT_SHOW = `show${EVENT_KEY}`
|
|
56
|
+
const EVENT_SHOWN = `shown${EVENT_KEY}`
|
|
57
|
+
const EVENT_HIDE = `hide${EVENT_KEY}`
|
|
58
|
+
const EVENT_HIDDEN = `hidden${EVENT_KEY}`
|
|
59
|
+
const EVENT_FOCUSIN = `focusin${EVENT_KEY}`
|
|
60
|
+
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
|
|
61
|
+
const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`
|
|
62
|
+
|
|
63
|
+
const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="offcanvas"]'
|
|
64
|
+
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="offcanvas"]'
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* ------------------------------------------------------------------------
|
|
68
|
+
* Class Definition
|
|
69
|
+
* ------------------------------------------------------------------------
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
class Offcanvas extends BaseComponent {
|
|
73
|
+
constructor(element, config) {
|
|
74
|
+
super(element)
|
|
75
|
+
|
|
76
|
+
this._config = this._getConfig(config)
|
|
77
|
+
this._isShown = false
|
|
78
|
+
this._addEventListeners()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Getters
|
|
82
|
+
|
|
83
|
+
static get Default() {
|
|
84
|
+
return Default
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static get DATA_KEY() {
|
|
88
|
+
return DATA_KEY
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Public
|
|
92
|
+
|
|
93
|
+
toggle(relatedTarget) {
|
|
94
|
+
return this._isShown ? this.hide() : this.show(relatedTarget)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
show(relatedTarget) {
|
|
98
|
+
if (this._isShown) {
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, { relatedTarget })
|
|
103
|
+
|
|
104
|
+
if (showEvent.defaultPrevented) {
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this._isShown = true
|
|
109
|
+
this._element.style.visibility = 'visible'
|
|
110
|
+
|
|
111
|
+
if (this._config.backdrop) {
|
|
112
|
+
document.body.classList.add(CLASS_NAME_BACKDROP_BODY)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!this._config.scroll) {
|
|
116
|
+
scrollBarHide()
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
this._element.classList.add(CLASS_NAME_TOGGLING)
|
|
120
|
+
this._element.removeAttribute('aria-hidden')
|
|
121
|
+
this._element.setAttribute('aria-modal', true)
|
|
122
|
+
this._element.setAttribute('role', 'dialog')
|
|
123
|
+
this._element.classList.add(CLASS_NAME_SHOW)
|
|
124
|
+
|
|
125
|
+
const completeCallBack = () => {
|
|
126
|
+
this._element.classList.remove(CLASS_NAME_TOGGLING)
|
|
127
|
+
EventHandler.trigger(this._element, EVENT_SHOWN, { relatedTarget })
|
|
128
|
+
this._enforceFocusOnElement(this._element)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
setTimeout(completeCallBack, getTransitionDurationFromElement(this._element))
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
hide() {
|
|
135
|
+
if (!this._isShown) {
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE)
|
|
140
|
+
|
|
141
|
+
if (hideEvent.defaultPrevented) {
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
this._element.classList.add(CLASS_NAME_TOGGLING)
|
|
146
|
+
EventHandler.off(document, EVENT_FOCUSIN)
|
|
147
|
+
this._element.blur()
|
|
148
|
+
this._isShown = false
|
|
149
|
+
this._element.classList.remove(CLASS_NAME_SHOW)
|
|
150
|
+
|
|
151
|
+
const completeCallback = () => {
|
|
152
|
+
this._element.setAttribute('aria-hidden', true)
|
|
153
|
+
this._element.removeAttribute('aria-modal')
|
|
154
|
+
this._element.removeAttribute('role')
|
|
155
|
+
this._element.style.visibility = 'hidden'
|
|
156
|
+
|
|
157
|
+
if (this._config.backdrop) {
|
|
158
|
+
document.body.classList.remove(CLASS_NAME_BACKDROP_BODY)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (!this._config.scroll) {
|
|
162
|
+
scrollBarReset()
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
EventHandler.trigger(this._element, EVENT_HIDDEN)
|
|
166
|
+
this._element.classList.remove(CLASS_NAME_TOGGLING)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
setTimeout(completeCallback, getTransitionDurationFromElement(this._element))
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Private
|
|
173
|
+
|
|
174
|
+
_getConfig(config) {
|
|
175
|
+
config = {
|
|
176
|
+
...Default,
|
|
177
|
+
...Manipulator.getDataAttributes(this._element),
|
|
178
|
+
...(typeof config === 'object' ? config : {})
|
|
179
|
+
}
|
|
180
|
+
typeCheckConfig(NAME, config, DefaultType)
|
|
181
|
+
return config
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
_enforceFocusOnElement(element) {
|
|
185
|
+
EventHandler.off(document, EVENT_FOCUSIN) // guard against infinite focus loop
|
|
186
|
+
EventHandler.on(document, EVENT_FOCUSIN, event => {
|
|
187
|
+
if (document !== event.target &&
|
|
188
|
+
element !== event.target &&
|
|
189
|
+
!element.contains(event.target)) {
|
|
190
|
+
element.focus()
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
element.focus()
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
_addEventListeners() {
|
|
197
|
+
EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, () => this.hide())
|
|
198
|
+
|
|
199
|
+
EventHandler.on(document, 'keydown', event => {
|
|
200
|
+
if (this._config.keyboard && event.key === ESCAPE_KEY) {
|
|
201
|
+
this.hide()
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, event => {
|
|
206
|
+
const target = SelectorEngine.findOne(getSelectorFromElement(event.target))
|
|
207
|
+
if (!this._element.contains(event.target) && target !== this._element) {
|
|
208
|
+
this.hide()
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Static
|
|
214
|
+
|
|
215
|
+
static jQueryInterface(config) {
|
|
216
|
+
return this.each(function () {
|
|
217
|
+
const data = Data.get(this, DATA_KEY) || new Offcanvas(this, typeof config === 'object' ? config : {})
|
|
218
|
+
|
|
219
|
+
if (typeof config !== 'string') {
|
|
220
|
+
return
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
|
|
224
|
+
throw new TypeError(`No method named "${config}"`)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
data[config](this)
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* ------------------------------------------------------------------------
|
|
234
|
+
* Data Api implementation
|
|
235
|
+
* ------------------------------------------------------------------------
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
|
239
|
+
const target = getElementFromSelector(this)
|
|
240
|
+
|
|
241
|
+
if (['A', 'AREA'].includes(this.tagName)) {
|
|
242
|
+
event.preventDefault()
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (isDisabled(this)) {
|
|
246
|
+
return
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
EventHandler.one(target, EVENT_HIDDEN, () => {
|
|
250
|
+
// focus on trigger when it is closed
|
|
251
|
+
if (isVisible(this)) {
|
|
252
|
+
this.focus()
|
|
253
|
+
}
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
// avoid conflict when clicking a toggler of an offcanvas, while another is open
|
|
257
|
+
const allReadyOpen = SelectorEngine.findOne(ACTIVE_SELECTOR)
|
|
258
|
+
if (allReadyOpen && allReadyOpen !== target) {
|
|
259
|
+
return
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const data = Data.get(target, DATA_KEY) || new Offcanvas(target)
|
|
263
|
+
|
|
264
|
+
data.toggle(this)
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
|
|
268
|
+
SelectorEngine.find(OPEN_SELECTOR).forEach(el => (Data.get(el, DATA_KEY) || new Offcanvas(el)).show())
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* ------------------------------------------------------------------------
|
|
273
|
+
* jQuery
|
|
274
|
+
* ------------------------------------------------------------------------
|
|
275
|
+
*/
|
|
276
|
+
|
|
277
|
+
defineJQueryPlugin(NAME, Offcanvas)
|
|
278
|
+
|
|
279
|
+
export default Offcanvas
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap (v5.0.0-beta3): popover.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { defineJQueryPlugin } from './util/index'
|
|
9
|
+
import Data from './dom/data'
|
|
10
|
+
import SelectorEngine from './dom/selector-engine'
|
|
11
|
+
import Tooltip from './tooltip'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* ------------------------------------------------------------------------
|
|
15
|
+
* Constants
|
|
16
|
+
* ------------------------------------------------------------------------
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const NAME = 'popover'
|
|
20
|
+
const DATA_KEY = 'bs.popover'
|
|
21
|
+
const EVENT_KEY = `.${DATA_KEY}`
|
|
22
|
+
const CLASS_PREFIX = 'bs-popover'
|
|
23
|
+
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
|
|
24
|
+
|
|
25
|
+
const Default = {
|
|
26
|
+
...Tooltip.Default,
|
|
27
|
+
placement: 'right',
|
|
28
|
+
offset: [0, 8],
|
|
29
|
+
trigger: 'click',
|
|
30
|
+
content: '',
|
|
31
|
+
template: '<div class="popover" role="tooltip">' +
|
|
32
|
+
'<div class="popover-arrow"></div>' +
|
|
33
|
+
'<h3 class="popover-header"></h3>' +
|
|
34
|
+
'<div class="popover-body"></div>' +
|
|
35
|
+
'</div>'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const DefaultType = {
|
|
39
|
+
...Tooltip.DefaultType,
|
|
40
|
+
content: '(string|element|function)'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const Event = {
|
|
44
|
+
HIDE: `hide${EVENT_KEY}`,
|
|
45
|
+
HIDDEN: `hidden${EVENT_KEY}`,
|
|
46
|
+
SHOW: `show${EVENT_KEY}`,
|
|
47
|
+
SHOWN: `shown${EVENT_KEY}`,
|
|
48
|
+
INSERTED: `inserted${EVENT_KEY}`,
|
|
49
|
+
CLICK: `click${EVENT_KEY}`,
|
|
50
|
+
FOCUSIN: `focusin${EVENT_KEY}`,
|
|
51
|
+
FOCUSOUT: `focusout${EVENT_KEY}`,
|
|
52
|
+
MOUSEENTER: `mouseenter${EVENT_KEY}`,
|
|
53
|
+
MOUSELEAVE: `mouseleave${EVENT_KEY}`
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const CLASS_NAME_FADE = 'fade'
|
|
57
|
+
const CLASS_NAME_SHOW = 'show'
|
|
58
|
+
|
|
59
|
+
const SELECTOR_TITLE = '.popover-header'
|
|
60
|
+
const SELECTOR_CONTENT = '.popover-body'
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* ------------------------------------------------------------------------
|
|
64
|
+
* Class Definition
|
|
65
|
+
* ------------------------------------------------------------------------
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
class Popover extends Tooltip {
|
|
69
|
+
// Getters
|
|
70
|
+
|
|
71
|
+
static get Default() {
|
|
72
|
+
return Default
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static get NAME() {
|
|
76
|
+
return NAME
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static get DATA_KEY() {
|
|
80
|
+
return DATA_KEY
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static get Event() {
|
|
84
|
+
return Event
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static get EVENT_KEY() {
|
|
88
|
+
return EVENT_KEY
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static get DefaultType() {
|
|
92
|
+
return DefaultType
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Overrides
|
|
96
|
+
|
|
97
|
+
isWithContent() {
|
|
98
|
+
return this.getTitle() || this._getContent()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
setContent() {
|
|
102
|
+
const tip = this.getTipElement()
|
|
103
|
+
|
|
104
|
+
// we use append for html objects to maintain js events
|
|
105
|
+
this.setElementContent(SelectorEngine.findOne(SELECTOR_TITLE, tip), this.getTitle())
|
|
106
|
+
let content = this._getContent()
|
|
107
|
+
if (typeof content === 'function') {
|
|
108
|
+
content = content.call(this._element)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
this.setElementContent(SelectorEngine.findOne(SELECTOR_CONTENT, tip), content)
|
|
112
|
+
|
|
113
|
+
tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Private
|
|
117
|
+
|
|
118
|
+
_addAttachmentClass(attachment) {
|
|
119
|
+
this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
_getContent() {
|
|
123
|
+
return this._element.getAttribute('data-bs-content') || this.config.content
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_cleanTipClass() {
|
|
127
|
+
const tip = this.getTipElement()
|
|
128
|
+
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX)
|
|
129
|
+
if (tabClass !== null && tabClass.length > 0) {
|
|
130
|
+
tabClass.map(token => token.trim())
|
|
131
|
+
.forEach(tClass => tip.classList.remove(tClass))
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Static
|
|
136
|
+
|
|
137
|
+
static jQueryInterface(config) {
|
|
138
|
+
return this.each(function () {
|
|
139
|
+
let data = Data.get(this, DATA_KEY)
|
|
140
|
+
const _config = typeof config === 'object' ? config : null
|
|
141
|
+
|
|
142
|
+
if (!data && /dispose|hide/.test(config)) {
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (!data) {
|
|
147
|
+
data = new Popover(this, _config)
|
|
148
|
+
Data.set(this, DATA_KEY, data)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (typeof config === 'string') {
|
|
152
|
+
if (typeof data[config] === 'undefined') {
|
|
153
|
+
throw new TypeError(`No method named "${config}"`)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
data[config]()
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* ------------------------------------------------------------------------
|
|
164
|
+
* jQuery
|
|
165
|
+
* ------------------------------------------------------------------------
|
|
166
|
+
* add .Popover to jQuery only if jQuery is present
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
defineJQueryPlugin(NAME, Popover)
|
|
170
|
+
|
|
171
|
+
export default Popover
|