bootstrap 5.0.2 → 5.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 +4 -4
- data/README.md +1 -1
- data/assets/javascripts/bootstrap-sprockets.js +7 -7
- data/assets/javascripts/bootstrap.js +590 -580
- data/assets/javascripts/bootstrap.min.js +2 -2
- data/assets/javascripts/bootstrap/alert.js +73 -43
- data/assets/javascripts/bootstrap/base-component.js +15 -10
- data/assets/javascripts/bootstrap/button.js +13 -6
- data/assets/javascripts/bootstrap/carousel.js +26 -8
- data/assets/javascripts/bootstrap/collapse.js +96 -114
- data/assets/javascripts/bootstrap/dom/data.js +2 -2
- data/assets/javascripts/bootstrap/dom/event-handler.js +9 -2
- data/assets/javascripts/bootstrap/dom/manipulator.js +4 -4
- data/assets/javascripts/bootstrap/dom/selector-engine.js +47 -5
- data/assets/javascripts/bootstrap/dropdown.js +66 -74
- data/assets/javascripts/bootstrap/modal.js +198 -52
- data/assets/javascripts/bootstrap/offcanvas.js +177 -31
- data/assets/javascripts/bootstrap/popover.js +19 -52
- data/assets/javascripts/bootstrap/scrollspy.js +28 -47
- data/assets/javascripts/bootstrap/tab.js +27 -8
- data/assets/javascripts/bootstrap/toast.js +108 -13
- data/assets/javascripts/bootstrap/tooltip.js +57 -47
- 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/_card.scss +2 -1
- data/assets/stylesheets/bootstrap/_functions.scss +45 -12
- data/assets/stylesheets/bootstrap/_grid.scss +11 -0
- data/assets/stylesheets/bootstrap/_helpers.scss +2 -0
- data/assets/stylesheets/bootstrap/_mixins.scss +1 -0
- data/assets/stylesheets/bootstrap/_modal.scss +1 -11
- data/assets/stylesheets/bootstrap/_navbar.scss +30 -1
- data/assets/stylesheets/bootstrap/_offcanvas.scss +4 -0
- data/assets/stylesheets/bootstrap/_placeholders.scss +51 -0
- data/assets/stylesheets/bootstrap/_reboot.scss +12 -8
- data/assets/stylesheets/bootstrap/_root.scss +39 -2
- data/assets/stylesheets/bootstrap/_toasts.scss +2 -2
- data/assets/stylesheets/bootstrap/_transitions.scss +6 -0
- data/assets/stylesheets/bootstrap/_utilities.scss +44 -8
- data/assets/stylesheets/bootstrap/_variables.scss +167 -6
- data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +1 -1
- data/assets/stylesheets/bootstrap/forms/_form-control.scss +1 -1
- data/assets/stylesheets/bootstrap/helpers/_stacks.scss +15 -0
- data/assets/stylesheets/bootstrap/helpers/_vr.scss +8 -0
- data/assets/stylesheets/bootstrap/mixins/_backdrop.scss +14 -0
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +25 -7
- data/assets/stylesheets/bootstrap/mixins/_utilities.scss +27 -6
- data/bootstrap.gemspec +3 -3
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +6 -2
- metadata +11 -7
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap offcanvas.js v5.0
|
2
|
+
* Bootstrap offcanvas.js v5.1.0 (https://getbootstrap.com/)
|
3
3
|
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
4
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
5
|
*/
|
@@ -16,6 +16,12 @@
|
|
16
16
|
var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
|
17
17
|
var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
|
18
18
|
|
19
|
+
/**
|
20
|
+
* --------------------------------------------------------------------------
|
21
|
+
* Bootstrap (v5.1.0): util/index.js
|
22
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
23
|
+
* --------------------------------------------------------------------------
|
24
|
+
*/
|
19
25
|
const MILLISECONDS_MULTIPLIER = 1000;
|
20
26
|
const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
|
21
27
|
|
@@ -102,7 +108,7 @@
|
|
102
108
|
}
|
103
109
|
|
104
110
|
if (typeof obj === 'string' && obj.length > 0) {
|
105
|
-
return
|
111
|
+
return document.querySelector(obj);
|
106
112
|
}
|
107
113
|
|
108
114
|
return null;
|
@@ -143,8 +149,20 @@
|
|
143
149
|
|
144
150
|
return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
|
145
151
|
};
|
152
|
+
/**
|
153
|
+
* Trick to restart an element's animation
|
154
|
+
*
|
155
|
+
* @param {HTMLElement} element
|
156
|
+
* @return void
|
157
|
+
*
|
158
|
+
* @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
|
159
|
+
*/
|
160
|
+
|
146
161
|
|
147
|
-
const reflow = element =>
|
162
|
+
const reflow = element => {
|
163
|
+
// eslint-disable-next-line no-unused-expressions
|
164
|
+
element.offsetHeight;
|
165
|
+
};
|
148
166
|
|
149
167
|
const getjQuery = () => {
|
150
168
|
const {
|
@@ -232,7 +250,7 @@
|
|
232
250
|
|
233
251
|
/**
|
234
252
|
* --------------------------------------------------------------------------
|
235
|
-
* Bootstrap (v5.0
|
253
|
+
* Bootstrap (v5.1.0): util/scrollBar.js
|
236
254
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
237
255
|
* --------------------------------------------------------------------------
|
238
256
|
*/
|
@@ -336,11 +354,12 @@
|
|
336
354
|
|
337
355
|
/**
|
338
356
|
* --------------------------------------------------------------------------
|
339
|
-
* Bootstrap (v5.0
|
357
|
+
* Bootstrap (v5.1.0): util/backdrop.js
|
340
358
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
341
359
|
* --------------------------------------------------------------------------
|
342
360
|
*/
|
343
|
-
const Default$
|
361
|
+
const Default$2 = {
|
362
|
+
className: 'modal-backdrop',
|
344
363
|
isVisible: true,
|
345
364
|
// if false, we use the backdrop helper without adding any element to the dom
|
346
365
|
isAnimated: false,
|
@@ -348,17 +367,17 @@
|
|
348
367
|
// give the choice to place backdrop under different elements
|
349
368
|
clickCallback: null
|
350
369
|
};
|
351
|
-
const DefaultType$
|
370
|
+
const DefaultType$2 = {
|
371
|
+
className: 'string',
|
352
372
|
isVisible: 'boolean',
|
353
373
|
isAnimated: 'boolean',
|
354
374
|
rootElement: '(element|string)',
|
355
375
|
clickCallback: '(function|null)'
|
356
376
|
};
|
357
|
-
const NAME$
|
358
|
-
const CLASS_NAME_BACKDROP = 'modal-backdrop';
|
377
|
+
const NAME$2 = 'backdrop';
|
359
378
|
const CLASS_NAME_FADE = 'fade';
|
360
379
|
const CLASS_NAME_SHOW$1 = 'show';
|
361
|
-
const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$
|
380
|
+
const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$2}`;
|
362
381
|
|
363
382
|
class Backdrop {
|
364
383
|
constructor(config) {
|
@@ -404,7 +423,7 @@
|
|
404
423
|
_getElement() {
|
405
424
|
if (!this._element) {
|
406
425
|
const backdrop = document.createElement('div');
|
407
|
-
backdrop.className =
|
426
|
+
backdrop.className = this._config.className;
|
408
427
|
|
409
428
|
if (this._config.isAnimated) {
|
410
429
|
backdrop.classList.add(CLASS_NAME_FADE);
|
@@ -417,12 +436,12 @@
|
|
417
436
|
}
|
418
437
|
|
419
438
|
_getConfig(config) {
|
420
|
-
config = { ...Default$
|
439
|
+
config = { ...Default$2,
|
421
440
|
...(typeof config === 'object' ? config : {})
|
422
441
|
}; // use getElement() with the default "body" to get a fresh Element on each instantiation
|
423
442
|
|
424
443
|
config.rootElement = getElement(config.rootElement);
|
425
|
-
typeCheckConfig(NAME$
|
444
|
+
typeCheckConfig(NAME$2, config, DefaultType$2);
|
426
445
|
return config;
|
427
446
|
}
|
428
447
|
|
@@ -431,7 +450,7 @@
|
|
431
450
|
return;
|
432
451
|
}
|
433
452
|
|
434
|
-
this._config.rootElement.
|
453
|
+
this._config.rootElement.append(this._getElement());
|
435
454
|
|
436
455
|
EventHandler__default['default'].on(this._getElement(), EVENT_MOUSEDOWN, () => {
|
437
456
|
execute(this._config.clickCallback);
|
@@ -459,7 +478,136 @@
|
|
459
478
|
|
460
479
|
/**
|
461
480
|
* --------------------------------------------------------------------------
|
462
|
-
* Bootstrap (v5.0
|
481
|
+
* Bootstrap (v5.1.0): util/focustrap.js
|
482
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
483
|
+
* --------------------------------------------------------------------------
|
484
|
+
*/
|
485
|
+
const Default$1 = {
|
486
|
+
trapElement: null,
|
487
|
+
// The element to trap focus inside of
|
488
|
+
autofocus: true
|
489
|
+
};
|
490
|
+
const DefaultType$1 = {
|
491
|
+
trapElement: 'element',
|
492
|
+
autofocus: 'boolean'
|
493
|
+
};
|
494
|
+
const NAME$1 = 'focustrap';
|
495
|
+
const DATA_KEY$1 = 'bs.focustrap';
|
496
|
+
const EVENT_KEY$1 = `.${DATA_KEY$1}`;
|
497
|
+
const EVENT_FOCUSIN = `focusin${EVENT_KEY$1}`;
|
498
|
+
const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$1}`;
|
499
|
+
const TAB_KEY = 'Tab';
|
500
|
+
const TAB_NAV_FORWARD = 'forward';
|
501
|
+
const TAB_NAV_BACKWARD = 'backward';
|
502
|
+
|
503
|
+
class FocusTrap {
|
504
|
+
constructor(config) {
|
505
|
+
this._config = this._getConfig(config);
|
506
|
+
this._isActive = false;
|
507
|
+
this._lastTabNavDirection = null;
|
508
|
+
}
|
509
|
+
|
510
|
+
activate() {
|
511
|
+
const {
|
512
|
+
trapElement,
|
513
|
+
autofocus
|
514
|
+
} = this._config;
|
515
|
+
|
516
|
+
if (this._isActive) {
|
517
|
+
return;
|
518
|
+
}
|
519
|
+
|
520
|
+
if (autofocus) {
|
521
|
+
trapElement.focus();
|
522
|
+
}
|
523
|
+
|
524
|
+
EventHandler__default['default'].off(document, EVENT_KEY$1); // guard against infinite focus loop
|
525
|
+
|
526
|
+
EventHandler__default['default'].on(document, EVENT_FOCUSIN, event => this._handleFocusin(event));
|
527
|
+
EventHandler__default['default'].on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
|
528
|
+
this._isActive = true;
|
529
|
+
}
|
530
|
+
|
531
|
+
deactivate() {
|
532
|
+
if (!this._isActive) {
|
533
|
+
return;
|
534
|
+
}
|
535
|
+
|
536
|
+
this._isActive = false;
|
537
|
+
EventHandler__default['default'].off(document, EVENT_KEY$1);
|
538
|
+
} // Private
|
539
|
+
|
540
|
+
|
541
|
+
_handleFocusin(event) {
|
542
|
+
const {
|
543
|
+
target
|
544
|
+
} = event;
|
545
|
+
const {
|
546
|
+
trapElement
|
547
|
+
} = this._config;
|
548
|
+
|
549
|
+
if (target === document || target === trapElement || trapElement.contains(target)) {
|
550
|
+
return;
|
551
|
+
}
|
552
|
+
|
553
|
+
const elements = SelectorEngine__default['default'].focusableChildren(trapElement);
|
554
|
+
|
555
|
+
if (elements.length === 0) {
|
556
|
+
trapElement.focus();
|
557
|
+
} else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
|
558
|
+
elements[elements.length - 1].focus();
|
559
|
+
} else {
|
560
|
+
elements[0].focus();
|
561
|
+
}
|
562
|
+
}
|
563
|
+
|
564
|
+
_handleKeydown(event) {
|
565
|
+
if (event.key !== TAB_KEY) {
|
566
|
+
return;
|
567
|
+
}
|
568
|
+
|
569
|
+
this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
|
570
|
+
}
|
571
|
+
|
572
|
+
_getConfig(config) {
|
573
|
+
config = { ...Default$1,
|
574
|
+
...(typeof config === 'object' ? config : {})
|
575
|
+
};
|
576
|
+
typeCheckConfig(NAME$1, config, DefaultType$1);
|
577
|
+
return config;
|
578
|
+
}
|
579
|
+
|
580
|
+
}
|
581
|
+
|
582
|
+
/**
|
583
|
+
* --------------------------------------------------------------------------
|
584
|
+
* Bootstrap (v5.1.0): util/component-functions.js
|
585
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
586
|
+
* --------------------------------------------------------------------------
|
587
|
+
*/
|
588
|
+
|
589
|
+
const enableDismissTrigger = (component, method = 'hide') => {
|
590
|
+
const clickEvent = `click.dismiss${component.EVENT_KEY}`;
|
591
|
+
const name = component.NAME;
|
592
|
+
EventHandler__default['default'].on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
|
593
|
+
if (['A', 'AREA'].includes(this.tagName)) {
|
594
|
+
event.preventDefault();
|
595
|
+
}
|
596
|
+
|
597
|
+
if (isDisabled(this)) {
|
598
|
+
return;
|
599
|
+
}
|
600
|
+
|
601
|
+
const target = getElementFromSelector(this) || this.closest(`.${name}`);
|
602
|
+
const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
|
603
|
+
|
604
|
+
instance[method]();
|
605
|
+
});
|
606
|
+
};
|
607
|
+
|
608
|
+
/**
|
609
|
+
* --------------------------------------------------------------------------
|
610
|
+
* Bootstrap (v5.1.0): offcanvas.js
|
463
611
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
464
612
|
* --------------------------------------------------------------------------
|
465
613
|
*/
|
@@ -486,16 +634,14 @@
|
|
486
634
|
scroll: 'boolean'
|
487
635
|
};
|
488
636
|
const CLASS_NAME_SHOW = 'show';
|
637
|
+
const CLASS_NAME_BACKDROP = 'offcanvas-backdrop';
|
489
638
|
const OPEN_SELECTOR = '.offcanvas.show';
|
490
639
|
const EVENT_SHOW = `show${EVENT_KEY}`;
|
491
640
|
const EVENT_SHOWN = `shown${EVENT_KEY}`;
|
492
641
|
const EVENT_HIDE = `hide${EVENT_KEY}`;
|
493
642
|
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
|
494
|
-
const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
|
495
643
|
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
|
496
|
-
const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`;
|
497
644
|
const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`;
|
498
|
-
const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="offcanvas"]';
|
499
645
|
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="offcanvas"]';
|
500
646
|
/**
|
501
647
|
* ------------------------------------------------------------------------
|
@@ -509,6 +655,7 @@
|
|
509
655
|
this._config = this._getConfig(config);
|
510
656
|
this._isShown = false;
|
511
657
|
this._backdrop = this._initializeBackDrop();
|
658
|
+
this._focustrap = this._initializeFocusTrap();
|
512
659
|
|
513
660
|
this._addEventListeners();
|
514
661
|
} // Getters
|
@@ -547,8 +694,6 @@
|
|
547
694
|
|
548
695
|
if (!this._config.scroll) {
|
549
696
|
new ScrollBarHelper().hide();
|
550
|
-
|
551
|
-
this._enforceFocusOnElement(this._element);
|
552
697
|
}
|
553
698
|
|
554
699
|
this._element.removeAttribute('aria-hidden');
|
@@ -560,6 +705,10 @@
|
|
560
705
|
this._element.classList.add(CLASS_NAME_SHOW);
|
561
706
|
|
562
707
|
const completeCallBack = () => {
|
708
|
+
if (!this._config.scroll) {
|
709
|
+
this._focustrap.activate();
|
710
|
+
}
|
711
|
+
|
563
712
|
EventHandler__default['default'].trigger(this._element, EVENT_SHOWN, {
|
564
713
|
relatedTarget
|
565
714
|
});
|
@@ -579,7 +728,7 @@
|
|
579
728
|
return;
|
580
729
|
}
|
581
730
|
|
582
|
-
|
731
|
+
this._focustrap.deactivate();
|
583
732
|
|
584
733
|
this._element.blur();
|
585
734
|
|
@@ -611,8 +760,9 @@
|
|
611
760
|
dispose() {
|
612
761
|
this._backdrop.dispose();
|
613
762
|
|
763
|
+
this._focustrap.deactivate();
|
764
|
+
|
614
765
|
super.dispose();
|
615
|
-
EventHandler__default['default'].off(document, EVENT_FOCUSIN);
|
616
766
|
} // Private
|
617
767
|
|
618
768
|
|
@@ -627,6 +777,7 @@
|
|
627
777
|
|
628
778
|
_initializeBackDrop() {
|
629
779
|
return new Backdrop({
|
780
|
+
className: CLASS_NAME_BACKDROP,
|
630
781
|
isVisible: this._config.backdrop,
|
631
782
|
isAnimated: true,
|
632
783
|
rootElement: this._element.parentNode,
|
@@ -634,19 +785,13 @@
|
|
634
785
|
});
|
635
786
|
}
|
636
787
|
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
EventHandler__default['default'].on(document, EVENT_FOCUSIN, event => {
|
641
|
-
if (document !== event.target && element !== event.target && !element.contains(event.target)) {
|
642
|
-
element.focus();
|
643
|
-
}
|
788
|
+
_initializeFocusTrap() {
|
789
|
+
return new FocusTrap({
|
790
|
+
trapElement: this._element
|
644
791
|
});
|
645
|
-
element.focus();
|
646
792
|
}
|
647
793
|
|
648
794
|
_addEventListeners() {
|
649
|
-
EventHandler__default['default'].on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, () => this.hide());
|
650
795
|
EventHandler__default['default'].on(this._element, EVENT_KEYDOWN_DISMISS, event => {
|
651
796
|
if (this._config.keyboard && event.key === ESCAPE_KEY) {
|
652
797
|
this.hide();
|
@@ -707,6 +852,7 @@
|
|
707
852
|
data.toggle(this);
|
708
853
|
});
|
709
854
|
EventHandler__default['default'].on(window, EVENT_LOAD_DATA_API, () => SelectorEngine__default['default'].find(OPEN_SELECTOR).forEach(el => Offcanvas.getOrCreateInstance(el).show()));
|
855
|
+
enableDismissTrigger(Offcanvas);
|
710
856
|
/**
|
711
857
|
* ------------------------------------------------------------------------
|
712
858
|
* jQuery
|
@@ -1,19 +1,25 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap popover.js v5.0
|
2
|
+
* Bootstrap popover.js v5.1.0 (https://getbootstrap.com/)
|
3
3
|
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
4
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
5
|
*/
|
6
6
|
(function (global, factory) {
|
7
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./
|
8
|
-
typeof define === 'function' && define.amd ? define(['./
|
9
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Popover = factory(global.
|
10
|
-
}(this, (function (
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./tooltip.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['./tooltip'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Popover = factory(global.Tooltip));
|
10
|
+
}(this, (function (Tooltip) { 'use strict';
|
11
11
|
|
12
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
13
13
|
|
14
|
-
var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
|
15
14
|
var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
|
16
15
|
|
16
|
+
/**
|
17
|
+
* --------------------------------------------------------------------------
|
18
|
+
* Bootstrap (v5.1.0): util/index.js
|
19
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
20
|
+
* --------------------------------------------------------------------------
|
21
|
+
*/
|
22
|
+
|
17
23
|
const getjQuery = () => {
|
18
24
|
const {
|
19
25
|
jQuery
|
@@ -64,7 +70,7 @@
|
|
64
70
|
|
65
71
|
/**
|
66
72
|
* --------------------------------------------------------------------------
|
67
|
-
* Bootstrap (v5.0
|
73
|
+
* Bootstrap (v5.1.0): popover.js
|
68
74
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
69
75
|
* --------------------------------------------------------------------------
|
70
76
|
*/
|
@@ -78,7 +84,6 @@
|
|
78
84
|
const DATA_KEY = 'bs.popover';
|
79
85
|
const EVENT_KEY = `.${DATA_KEY}`;
|
80
86
|
const CLASS_PREFIX = 'bs-popover';
|
81
|
-
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g');
|
82
87
|
const Default = { ...Tooltip__default['default'].Default,
|
83
88
|
placement: 'right',
|
84
89
|
offset: [0, 8],
|
@@ -101,8 +106,6 @@
|
|
101
106
|
MOUSEENTER: `mouseenter${EVENT_KEY}`,
|
102
107
|
MOUSELEAVE: `mouseleave${EVENT_KEY}`
|
103
108
|
};
|
104
|
-
const CLASS_NAME_FADE = 'fade';
|
105
|
-
const CLASS_NAME_SHOW = 'show';
|
106
109
|
const SELECTOR_TITLE = '.popover-header';
|
107
110
|
const SELECTOR_CONTENT = '.popover-body';
|
108
111
|
/**
|
@@ -134,55 +137,19 @@
|
|
134
137
|
return this.getTitle() || this._getContent();
|
135
138
|
}
|
136
139
|
|
137
|
-
|
138
|
-
|
139
|
-
return this.tip;
|
140
|
-
}
|
141
|
-
|
142
|
-
this.tip = super.getTipElement();
|
143
|
-
|
144
|
-
if (!this.getTitle()) {
|
145
|
-
SelectorEngine__default['default'].findOne(SELECTOR_TITLE, this.tip).remove();
|
146
|
-
}
|
147
|
-
|
148
|
-
if (!this._getContent()) {
|
149
|
-
SelectorEngine__default['default'].findOne(SELECTOR_CONTENT, this.tip).remove();
|
150
|
-
}
|
140
|
+
setContent(tip) {
|
141
|
+
this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TITLE);
|
151
142
|
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
setContent() {
|
156
|
-
const tip = this.getTipElement(); // we use append for html objects to maintain js events
|
157
|
-
|
158
|
-
this.setElementContent(SelectorEngine__default['default'].findOne(SELECTOR_TITLE, tip), this.getTitle());
|
159
|
-
|
160
|
-
let content = this._getContent();
|
161
|
-
|
162
|
-
if (typeof content === 'function') {
|
163
|
-
content = content.call(this._element);
|
164
|
-
}
|
165
|
-
|
166
|
-
this.setElementContent(SelectorEngine__default['default'].findOne(SELECTOR_CONTENT, tip), content);
|
167
|
-
tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
|
143
|
+
this._sanitizeAndSetContent(tip, this._getContent(), SELECTOR_CONTENT);
|
168
144
|
} // Private
|
169
145
|
|
170
146
|
|
171
|
-
_addAttachmentClass(attachment) {
|
172
|
-
this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`);
|
173
|
-
}
|
174
|
-
|
175
147
|
_getContent() {
|
176
|
-
return this.
|
148
|
+
return this._resolvePossibleFunction(this._config.content);
|
177
149
|
}
|
178
150
|
|
179
|
-
|
180
|
-
|
181
|
-
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX);
|
182
|
-
|
183
|
-
if (tabClass !== null && tabClass.length > 0) {
|
184
|
-
tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass));
|
185
|
-
}
|
151
|
+
_getBasicClassPrefix() {
|
152
|
+
return CLASS_PREFIX;
|
186
153
|
} // Static
|
187
154
|
|
188
155
|
|