bootstrap 5.0.0.beta2 → 5.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/assets/javascripts/bootstrap-sprockets.js +1 -0
- data/assets/javascripts/bootstrap.js +2051 -2009
- data/assets/javascripts/bootstrap.min.js +2 -2
- data/assets/javascripts/bootstrap/alert.js +75 -118
- data/assets/javascripts/bootstrap/base-component.js +23 -37
- data/assets/javascripts/bootstrap/button.js +39 -78
- data/assets/javascripts/bootstrap/carousel.js +284 -364
- data/assets/javascripts/bootstrap/collapse.js +178 -247
- data/assets/javascripts/bootstrap/dom/data.js +34 -47
- data/assets/javascripts/bootstrap/dom/event-handler.js +71 -77
- data/assets/javascripts/bootstrap/dom/manipulator.js +23 -21
- data/assets/javascripts/bootstrap/dom/selector-engine.js +20 -28
- data/assets/javascripts/bootstrap/dropdown.js +195 -265
- data/assets/javascripts/bootstrap/modal.js +256 -344
- data/assets/javascripts/bootstrap/offcanvas.js +508 -0
- data/assets/javascripts/bootstrap/popover.js +88 -157
- data/assets/javascripts/bootstrap/scrollspy.js +134 -212
- data/assets/javascripts/bootstrap/tab.js +108 -142
- data/assets/javascripts/bootstrap/toast.js +113 -183
- data/assets/javascripts/bootstrap/tooltip.js +297 -392
- data/assets/stylesheets/_bootstrap-grid.scss +1 -1
- data/assets/stylesheets/_bootstrap-reboot.scss +1 -1
- data/assets/stylesheets/_bootstrap.scss +2 -1
- data/assets/stylesheets/bootstrap/_accordion.scss +22 -32
- data/assets/stylesheets/bootstrap/_buttons.scss +2 -0
- data/assets/stylesheets/bootstrap/_card.scss +1 -1
- data/assets/stylesheets/bootstrap/_dropdown.scss +3 -6
- data/assets/stylesheets/bootstrap/_list-group.scss +11 -0
- data/assets/stylesheets/bootstrap/_modal.scss +2 -0
- data/assets/stylesheets/bootstrap/_nav.scss +7 -0
- data/assets/stylesheets/bootstrap/_navbar.scss +2 -0
- data/assets/stylesheets/bootstrap/_offcanvas.scss +77 -0
- data/assets/stylesheets/bootstrap/_progress.scss +3 -0
- data/assets/stylesheets/bootstrap/_reboot.scss +7 -21
- data/assets/stylesheets/bootstrap/_spinners.scss +4 -0
- data/assets/stylesheets/bootstrap/_transitions.scss +2 -0
- data/assets/stylesheets/bootstrap/_utilities.scss +65 -37
- data/assets/stylesheets/bootstrap/_variables.scss +138 -30
- data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +1 -1
- data/assets/stylesheets/bootstrap/forms/_form-control.scss +0 -4
- data/assets/stylesheets/bootstrap/mixins/_alert.scss +2 -0
- data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +2 -0
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +6 -1
- data/assets/stylesheets/bootstrap/mixins/_caret.scss +2 -0
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +11 -1
- data/assets/stylesheets/bootstrap/mixins/_list-group.scss +2 -0
- data/assets/stylesheets/bootstrap/mixins/_pagination.scss +2 -0
- data/bootstrap.gemspec +1 -1
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +1 -1
- data/tasks/updater/network.rb +7 -1
- metadata +6 -4
@@ -0,0 +1,508 @@
|
|
1
|
+
/*!
|
2
|
+
* Bootstrap offcanvas.js v5.0.0-beta3 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
|
+
*/
|
6
|
+
(function (global, factory) {
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/selector-engine.js'), require('./dom/manipulator.js'), require('./dom/data.js'), require('./dom/event-handler.js'), require('./base-component.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['./dom/selector-engine', './dom/manipulator', './dom/data', './dom/event-handler', './base-component'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Offcanvas = factory(global.SelectorEngine, global.Manipulator, global.Data, global.EventHandler, global.Base));
|
10
|
+
}(this, (function (SelectorEngine, Manipulator, Data, EventHandler, BaseComponent) { 'use strict';
|
11
|
+
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
13
|
+
|
14
|
+
var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
|
15
|
+
var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
|
16
|
+
var Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
|
17
|
+
var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
|
18
|
+
var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
|
19
|
+
|
20
|
+
/**
|
21
|
+
* --------------------------------------------------------------------------
|
22
|
+
* Bootstrap (v5.0.0-beta3): util/index.js
|
23
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
24
|
+
* --------------------------------------------------------------------------
|
25
|
+
*/
|
26
|
+
const MILLISECONDS_MULTIPLIER = 1000;
|
27
|
+
|
28
|
+
const toType = obj => {
|
29
|
+
if (obj === null || obj === undefined) {
|
30
|
+
return `${obj}`;
|
31
|
+
}
|
32
|
+
|
33
|
+
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
|
34
|
+
};
|
35
|
+
|
36
|
+
const getSelector = element => {
|
37
|
+
let selector = element.getAttribute('data-bs-target');
|
38
|
+
|
39
|
+
if (!selector || selector === '#') {
|
40
|
+
let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
|
41
|
+
// so everything starting with `#` or `.`. If a "real" URL is used as the selector,
|
42
|
+
// `document.querySelector` will rightfully complain it is invalid.
|
43
|
+
// See https://github.com/twbs/bootstrap/issues/32273
|
44
|
+
|
45
|
+
if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
|
46
|
+
return null;
|
47
|
+
} // Just in case some CMS puts out a full URL with the anchor appended
|
48
|
+
|
49
|
+
|
50
|
+
if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
|
51
|
+
hrefAttr = '#' + hrefAttr.split('#')[1];
|
52
|
+
}
|
53
|
+
|
54
|
+
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
|
55
|
+
}
|
56
|
+
|
57
|
+
return selector;
|
58
|
+
};
|
59
|
+
|
60
|
+
const getSelectorFromElement = element => {
|
61
|
+
const selector = getSelector(element);
|
62
|
+
|
63
|
+
if (selector) {
|
64
|
+
return document.querySelector(selector) ? selector : null;
|
65
|
+
}
|
66
|
+
|
67
|
+
return null;
|
68
|
+
};
|
69
|
+
|
70
|
+
const getElementFromSelector = element => {
|
71
|
+
const selector = getSelector(element);
|
72
|
+
return selector ? document.querySelector(selector) : null;
|
73
|
+
};
|
74
|
+
|
75
|
+
const getTransitionDurationFromElement = element => {
|
76
|
+
if (!element) {
|
77
|
+
return 0;
|
78
|
+
} // Get transition-duration of the element
|
79
|
+
|
80
|
+
|
81
|
+
let {
|
82
|
+
transitionDuration,
|
83
|
+
transitionDelay
|
84
|
+
} = window.getComputedStyle(element);
|
85
|
+
const floatTransitionDuration = Number.parseFloat(transitionDuration);
|
86
|
+
const floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
|
87
|
+
|
88
|
+
if (!floatTransitionDuration && !floatTransitionDelay) {
|
89
|
+
return 0;
|
90
|
+
} // If multiple durations are defined, take the first
|
91
|
+
|
92
|
+
|
93
|
+
transitionDuration = transitionDuration.split(',')[0];
|
94
|
+
transitionDelay = transitionDelay.split(',')[0];
|
95
|
+
return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
|
96
|
+
};
|
97
|
+
|
98
|
+
const isElement = obj => (obj[0] || obj).nodeType;
|
99
|
+
|
100
|
+
const typeCheckConfig = (componentName, config, configTypes) => {
|
101
|
+
Object.keys(configTypes).forEach(property => {
|
102
|
+
const expectedTypes = configTypes[property];
|
103
|
+
const value = config[property];
|
104
|
+
const valueType = value && isElement(value) ? 'element' : toType(value);
|
105
|
+
|
106
|
+
if (!new RegExp(expectedTypes).test(valueType)) {
|
107
|
+
throw new TypeError(`${componentName.toUpperCase()}: ` + `Option "${property}" provided type "${valueType}" ` + `but expected type "${expectedTypes}".`);
|
108
|
+
}
|
109
|
+
});
|
110
|
+
};
|
111
|
+
|
112
|
+
const isVisible = element => {
|
113
|
+
if (!element) {
|
114
|
+
return false;
|
115
|
+
}
|
116
|
+
|
117
|
+
if (element.style && element.parentNode && element.parentNode.style) {
|
118
|
+
const elementStyle = getComputedStyle(element);
|
119
|
+
const parentNodeStyle = getComputedStyle(element.parentNode);
|
120
|
+
return elementStyle.display !== 'none' && parentNodeStyle.display !== 'none' && elementStyle.visibility !== 'hidden';
|
121
|
+
}
|
122
|
+
|
123
|
+
return false;
|
124
|
+
};
|
125
|
+
|
126
|
+
const isDisabled = element => {
|
127
|
+
if (!element || element.nodeType !== Node.ELEMENT_NODE) {
|
128
|
+
return true;
|
129
|
+
}
|
130
|
+
|
131
|
+
if (element.classList.contains('disabled')) {
|
132
|
+
return true;
|
133
|
+
}
|
134
|
+
|
135
|
+
if (typeof element.disabled !== 'undefined') {
|
136
|
+
return element.disabled;
|
137
|
+
}
|
138
|
+
|
139
|
+
return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
|
140
|
+
};
|
141
|
+
|
142
|
+
const getjQuery = () => {
|
143
|
+
const {
|
144
|
+
jQuery
|
145
|
+
} = window;
|
146
|
+
|
147
|
+
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
|
148
|
+
return jQuery;
|
149
|
+
}
|
150
|
+
|
151
|
+
return null;
|
152
|
+
};
|
153
|
+
|
154
|
+
const onDOMContentLoaded = callback => {
|
155
|
+
if (document.readyState === 'loading') {
|
156
|
+
document.addEventListener('DOMContentLoaded', callback);
|
157
|
+
} else {
|
158
|
+
callback();
|
159
|
+
}
|
160
|
+
};
|
161
|
+
|
162
|
+
const defineJQueryPlugin = (name, plugin) => {
|
163
|
+
onDOMContentLoaded(() => {
|
164
|
+
const $ = getjQuery();
|
165
|
+
/* istanbul ignore if */
|
166
|
+
|
167
|
+
if ($) {
|
168
|
+
const JQUERY_NO_CONFLICT = $.fn[name];
|
169
|
+
$.fn[name] = plugin.jQueryInterface;
|
170
|
+
$.fn[name].Constructor = plugin;
|
171
|
+
|
172
|
+
$.fn[name].noConflict = () => {
|
173
|
+
$.fn[name] = JQUERY_NO_CONFLICT;
|
174
|
+
return plugin.jQueryInterface;
|
175
|
+
};
|
176
|
+
}
|
177
|
+
});
|
178
|
+
};
|
179
|
+
|
180
|
+
/**
|
181
|
+
* --------------------------------------------------------------------------
|
182
|
+
* Bootstrap (v5.0.0-beta3): util/scrollBar.js
|
183
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
184
|
+
* --------------------------------------------------------------------------
|
185
|
+
*/
|
186
|
+
const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed';
|
187
|
+
const SELECTOR_STICKY_CONTENT = '.sticky-top';
|
188
|
+
|
189
|
+
const getWidth = () => {
|
190
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
|
191
|
+
const documentWidth = document.documentElement.clientWidth;
|
192
|
+
return Math.abs(window.innerWidth - documentWidth);
|
193
|
+
};
|
194
|
+
|
195
|
+
const hide = (width = getWidth()) => {
|
196
|
+
document.body.style.overflow = 'hidden';
|
197
|
+
|
198
|
+
_setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width);
|
199
|
+
|
200
|
+
_setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width);
|
201
|
+
|
202
|
+
_setElementAttributes('body', 'paddingRight', calculatedValue => calculatedValue + width);
|
203
|
+
};
|
204
|
+
|
205
|
+
const _setElementAttributes = (selector, styleProp, callback) => {
|
206
|
+
const scrollbarWidth = getWidth();
|
207
|
+
SelectorEngine__default['default'].find(selector).forEach(element => {
|
208
|
+
if (element !== document.body && window.innerWidth > element.clientWidth + scrollbarWidth) {
|
209
|
+
return;
|
210
|
+
}
|
211
|
+
|
212
|
+
const actualValue = element.style[styleProp];
|
213
|
+
const calculatedValue = window.getComputedStyle(element)[styleProp];
|
214
|
+
Manipulator__default['default'].setDataAttribute(element, styleProp, actualValue);
|
215
|
+
element.style[styleProp] = callback(Number.parseFloat(calculatedValue)) + 'px';
|
216
|
+
});
|
217
|
+
};
|
218
|
+
|
219
|
+
const reset = () => {
|
220
|
+
document.body.style.overflow = 'auto';
|
221
|
+
|
222
|
+
_resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight');
|
223
|
+
|
224
|
+
_resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight');
|
225
|
+
|
226
|
+
_resetElementAttributes('body', 'paddingRight');
|
227
|
+
};
|
228
|
+
|
229
|
+
const _resetElementAttributes = (selector, styleProp) => {
|
230
|
+
SelectorEngine__default['default'].find(selector).forEach(element => {
|
231
|
+
const value = Manipulator__default['default'].getDataAttribute(element, styleProp);
|
232
|
+
|
233
|
+
if (typeof value === 'undefined' && element === document.body) {
|
234
|
+
element.style.removeProperty(styleProp);
|
235
|
+
} else {
|
236
|
+
Manipulator__default['default'].removeDataAttribute(element, styleProp);
|
237
|
+
element.style[styleProp] = value;
|
238
|
+
}
|
239
|
+
});
|
240
|
+
};
|
241
|
+
|
242
|
+
/**
|
243
|
+
* --------------------------------------------------------------------------
|
244
|
+
* Bootstrap (v5.0.0-beta3): offcanvas.js
|
245
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
246
|
+
* --------------------------------------------------------------------------
|
247
|
+
*/
|
248
|
+
/**
|
249
|
+
* ------------------------------------------------------------------------
|
250
|
+
* Constants
|
251
|
+
* ------------------------------------------------------------------------
|
252
|
+
*/
|
253
|
+
|
254
|
+
const NAME = 'offcanvas';
|
255
|
+
const DATA_KEY = 'bs.offcanvas';
|
256
|
+
const EVENT_KEY = `.${DATA_KEY}`;
|
257
|
+
const DATA_API_KEY = '.data-api';
|
258
|
+
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
|
259
|
+
const ESCAPE_KEY = 'Escape';
|
260
|
+
const Default = {
|
261
|
+
backdrop: true,
|
262
|
+
keyboard: true,
|
263
|
+
scroll: false
|
264
|
+
};
|
265
|
+
const DefaultType = {
|
266
|
+
backdrop: 'boolean',
|
267
|
+
keyboard: 'boolean',
|
268
|
+
scroll: 'boolean'
|
269
|
+
};
|
270
|
+
const CLASS_NAME_BACKDROP_BODY = 'offcanvas-backdrop';
|
271
|
+
const CLASS_NAME_SHOW = 'show';
|
272
|
+
const CLASS_NAME_TOGGLING = 'offcanvas-toggling';
|
273
|
+
const OPEN_SELECTOR = '.offcanvas.show';
|
274
|
+
const ACTIVE_SELECTOR = `${OPEN_SELECTOR}, .${CLASS_NAME_TOGGLING}`;
|
275
|
+
const EVENT_SHOW = `show${EVENT_KEY}`;
|
276
|
+
const EVENT_SHOWN = `shown${EVENT_KEY}`;
|
277
|
+
const EVENT_HIDE = `hide${EVENT_KEY}`;
|
278
|
+
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
|
279
|
+
const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
|
280
|
+
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
|
281
|
+
const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`;
|
282
|
+
const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="offcanvas"]';
|
283
|
+
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="offcanvas"]';
|
284
|
+
/**
|
285
|
+
* ------------------------------------------------------------------------
|
286
|
+
* Class Definition
|
287
|
+
* ------------------------------------------------------------------------
|
288
|
+
*/
|
289
|
+
|
290
|
+
class Offcanvas extends BaseComponent__default['default'] {
|
291
|
+
constructor(element, config) {
|
292
|
+
super(element);
|
293
|
+
this._config = this._getConfig(config);
|
294
|
+
this._isShown = false;
|
295
|
+
|
296
|
+
this._addEventListeners();
|
297
|
+
} // Getters
|
298
|
+
|
299
|
+
|
300
|
+
static get Default() {
|
301
|
+
return Default;
|
302
|
+
}
|
303
|
+
|
304
|
+
static get DATA_KEY() {
|
305
|
+
return DATA_KEY;
|
306
|
+
} // Public
|
307
|
+
|
308
|
+
|
309
|
+
toggle(relatedTarget) {
|
310
|
+
return this._isShown ? this.hide() : this.show(relatedTarget);
|
311
|
+
}
|
312
|
+
|
313
|
+
show(relatedTarget) {
|
314
|
+
if (this._isShown) {
|
315
|
+
return;
|
316
|
+
}
|
317
|
+
|
318
|
+
const showEvent = EventHandler__default['default'].trigger(this._element, EVENT_SHOW, {
|
319
|
+
relatedTarget
|
320
|
+
});
|
321
|
+
|
322
|
+
if (showEvent.defaultPrevented) {
|
323
|
+
return;
|
324
|
+
}
|
325
|
+
|
326
|
+
this._isShown = true;
|
327
|
+
this._element.style.visibility = 'visible';
|
328
|
+
|
329
|
+
if (this._config.backdrop) {
|
330
|
+
document.body.classList.add(CLASS_NAME_BACKDROP_BODY);
|
331
|
+
}
|
332
|
+
|
333
|
+
if (!this._config.scroll) {
|
334
|
+
hide();
|
335
|
+
}
|
336
|
+
|
337
|
+
this._element.classList.add(CLASS_NAME_TOGGLING);
|
338
|
+
|
339
|
+
this._element.removeAttribute('aria-hidden');
|
340
|
+
|
341
|
+
this._element.setAttribute('aria-modal', true);
|
342
|
+
|
343
|
+
this._element.setAttribute('role', 'dialog');
|
344
|
+
|
345
|
+
this._element.classList.add(CLASS_NAME_SHOW);
|
346
|
+
|
347
|
+
const completeCallBack = () => {
|
348
|
+
this._element.classList.remove(CLASS_NAME_TOGGLING);
|
349
|
+
|
350
|
+
EventHandler__default['default'].trigger(this._element, EVENT_SHOWN, {
|
351
|
+
relatedTarget
|
352
|
+
});
|
353
|
+
|
354
|
+
this._enforceFocusOnElement(this._element);
|
355
|
+
};
|
356
|
+
|
357
|
+
setTimeout(completeCallBack, getTransitionDurationFromElement(this._element));
|
358
|
+
}
|
359
|
+
|
360
|
+
hide() {
|
361
|
+
if (!this._isShown) {
|
362
|
+
return;
|
363
|
+
}
|
364
|
+
|
365
|
+
const hideEvent = EventHandler__default['default'].trigger(this._element, EVENT_HIDE);
|
366
|
+
|
367
|
+
if (hideEvent.defaultPrevented) {
|
368
|
+
return;
|
369
|
+
}
|
370
|
+
|
371
|
+
this._element.classList.add(CLASS_NAME_TOGGLING);
|
372
|
+
|
373
|
+
EventHandler__default['default'].off(document, EVENT_FOCUSIN);
|
374
|
+
|
375
|
+
this._element.blur();
|
376
|
+
|
377
|
+
this._isShown = false;
|
378
|
+
|
379
|
+
this._element.classList.remove(CLASS_NAME_SHOW);
|
380
|
+
|
381
|
+
const completeCallback = () => {
|
382
|
+
this._element.setAttribute('aria-hidden', true);
|
383
|
+
|
384
|
+
this._element.removeAttribute('aria-modal');
|
385
|
+
|
386
|
+
this._element.removeAttribute('role');
|
387
|
+
|
388
|
+
this._element.style.visibility = 'hidden';
|
389
|
+
|
390
|
+
if (this._config.backdrop) {
|
391
|
+
document.body.classList.remove(CLASS_NAME_BACKDROP_BODY);
|
392
|
+
}
|
393
|
+
|
394
|
+
if (!this._config.scroll) {
|
395
|
+
reset();
|
396
|
+
}
|
397
|
+
|
398
|
+
EventHandler__default['default'].trigger(this._element, EVENT_HIDDEN);
|
399
|
+
|
400
|
+
this._element.classList.remove(CLASS_NAME_TOGGLING);
|
401
|
+
};
|
402
|
+
|
403
|
+
setTimeout(completeCallback, getTransitionDurationFromElement(this._element));
|
404
|
+
} // Private
|
405
|
+
|
406
|
+
|
407
|
+
_getConfig(config) {
|
408
|
+
config = { ...Default,
|
409
|
+
...Manipulator__default['default'].getDataAttributes(this._element),
|
410
|
+
...(typeof config === 'object' ? config : {})
|
411
|
+
};
|
412
|
+
typeCheckConfig(NAME, config, DefaultType);
|
413
|
+
return config;
|
414
|
+
}
|
415
|
+
|
416
|
+
_enforceFocusOnElement(element) {
|
417
|
+
EventHandler__default['default'].off(document, EVENT_FOCUSIN); // guard against infinite focus loop
|
418
|
+
|
419
|
+
EventHandler__default['default'].on(document, EVENT_FOCUSIN, event => {
|
420
|
+
if (document !== event.target && element !== event.target && !element.contains(event.target)) {
|
421
|
+
element.focus();
|
422
|
+
}
|
423
|
+
});
|
424
|
+
element.focus();
|
425
|
+
}
|
426
|
+
|
427
|
+
_addEventListeners() {
|
428
|
+
EventHandler__default['default'].on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, () => this.hide());
|
429
|
+
EventHandler__default['default'].on(document, 'keydown', event => {
|
430
|
+
if (this._config.keyboard && event.key === ESCAPE_KEY) {
|
431
|
+
this.hide();
|
432
|
+
}
|
433
|
+
});
|
434
|
+
EventHandler__default['default'].on(document, EVENT_CLICK_DATA_API, event => {
|
435
|
+
const target = SelectorEngine__default['default'].findOne(getSelectorFromElement(event.target));
|
436
|
+
|
437
|
+
if (!this._element.contains(event.target) && target !== this._element) {
|
438
|
+
this.hide();
|
439
|
+
}
|
440
|
+
});
|
441
|
+
} // Static
|
442
|
+
|
443
|
+
|
444
|
+
static jQueryInterface(config) {
|
445
|
+
return this.each(function () {
|
446
|
+
const data = Data__default['default'].get(this, DATA_KEY) || new Offcanvas(this, typeof config === 'object' ? config : {});
|
447
|
+
|
448
|
+
if (typeof config !== 'string') {
|
449
|
+
return;
|
450
|
+
}
|
451
|
+
|
452
|
+
if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
|
453
|
+
throw new TypeError(`No method named "${config}"`);
|
454
|
+
}
|
455
|
+
|
456
|
+
data[config](this);
|
457
|
+
});
|
458
|
+
}
|
459
|
+
|
460
|
+
}
|
461
|
+
/**
|
462
|
+
* ------------------------------------------------------------------------
|
463
|
+
* Data Api implementation
|
464
|
+
* ------------------------------------------------------------------------
|
465
|
+
*/
|
466
|
+
|
467
|
+
|
468
|
+
EventHandler__default['default'].on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
469
|
+
const target = getElementFromSelector(this);
|
470
|
+
|
471
|
+
if (['A', 'AREA'].includes(this.tagName)) {
|
472
|
+
event.preventDefault();
|
473
|
+
}
|
474
|
+
|
475
|
+
if (isDisabled(this)) {
|
476
|
+
return;
|
477
|
+
}
|
478
|
+
|
479
|
+
EventHandler__default['default'].one(target, EVENT_HIDDEN, () => {
|
480
|
+
// focus on trigger when it is closed
|
481
|
+
if (isVisible(this)) {
|
482
|
+
this.focus();
|
483
|
+
}
|
484
|
+
}); // avoid conflict when clicking a toggler of an offcanvas, while another is open
|
485
|
+
|
486
|
+
const allReadyOpen = SelectorEngine__default['default'].findOne(ACTIVE_SELECTOR);
|
487
|
+
|
488
|
+
if (allReadyOpen && allReadyOpen !== target) {
|
489
|
+
return;
|
490
|
+
}
|
491
|
+
|
492
|
+
const data = Data__default['default'].get(target, DATA_KEY) || new Offcanvas(target);
|
493
|
+
data.toggle(this);
|
494
|
+
});
|
495
|
+
EventHandler__default['default'].on(window, EVENT_LOAD_DATA_API, () => {
|
496
|
+
SelectorEngine__default['default'].find(OPEN_SELECTOR).forEach(el => (Data__default['default'].get(el, DATA_KEY) || new Offcanvas(el)).show());
|
497
|
+
});
|
498
|
+
/**
|
499
|
+
* ------------------------------------------------------------------------
|
500
|
+
* jQuery
|
501
|
+
* ------------------------------------------------------------------------
|
502
|
+
*/
|
503
|
+
|
504
|
+
defineJQueryPlugin(NAME, Offcanvas);
|
505
|
+
|
506
|
+
return Offcanvas;
|
507
|
+
|
508
|
+
})));
|