source: imaps-frontend/node_modules/bootstrap/js/src/popover.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 * --------------------------------------------------------------------------
3 * Bootstrap popover.js
4 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5 * --------------------------------------------------------------------------
6 */
7
8import Tooltip from './tooltip.js'
9import { defineJQueryPlugin } from './util/index.js'
10
11/**
12 * Constants
13 */
14
15const NAME = 'popover'
16
17const SELECTOR_TITLE = '.popover-header'
18const SELECTOR_CONTENT = '.popover-body'
19
20const Default = {
21 ...Tooltip.Default,
22 content: '',
23 offset: [0, 8],
24 placement: 'right',
25 template: '<div class="popover" role="tooltip">' +
26 '<div class="popover-arrow"></div>' +
27 '<h3 class="popover-header"></h3>' +
28 '<div class="popover-body"></div>' +
29 '</div>',
30 trigger: 'click'
31}
32
33const DefaultType = {
34 ...Tooltip.DefaultType,
35 content: '(null|string|element|function)'
36}
37
38/**
39 * Class definition
40 */
41
42class Popover extends Tooltip {
43 // Getters
44 static get Default() {
45 return Default
46 }
47
48 static get DefaultType() {
49 return DefaultType
50 }
51
52 static get NAME() {
53 return NAME
54 }
55
56 // Overrides
57 _isWithContent() {
58 return this._getTitle() || this._getContent()
59 }
60
61 // Private
62 _getContentForTemplate() {
63 return {
64 [SELECTOR_TITLE]: this._getTitle(),
65 [SELECTOR_CONTENT]: this._getContent()
66 }
67 }
68
69 _getContent() {
70 return this._resolvePossibleFunction(this._config.content)
71 }
72
73 // Static
74 static jQueryInterface(config) {
75 return this.each(function () {
76 const data = Popover.getOrCreateInstance(this, config)
77
78 if (typeof config !== 'string') {
79 return
80 }
81
82 if (typeof data[config] === 'undefined') {
83 throw new TypeError(`No method named "${config}"`)
84 }
85
86 data[config]()
87 })
88 }
89}
90
91/**
92 * jQuery
93 */
94
95defineJQueryPlugin(Popover)
96
97export default Popover
Note: See TracBrowser for help on using the repository browser.