]>
git.ipfire.org Git - ipfire.org.git/blob - static/scss/bootstrap-4.0.0-alpha.6/js/src/popover.js
1 import Tooltip
from './tooltip'
5 * --------------------------------------------------------------------------
6 * Bootstrap (v4.0.0-alpha.6): popover.js
7 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
8 * --------------------------------------------------------------------------
11 const Popover
= (($) => {
15 * ------------------------------------------------------------------------
17 * ------------------------------------------------------------------------
20 const NAME
= 'popover'
21 const VERSION
= '4.0.0-alpha.6'
22 const DATA_KEY
= 'bs.popover'
23 const EVENT_KEY
= `.${DATA_KEY}`
24 const JQUERY_NO_CONFLICT
= $.fn
[NAME
]
26 const Default
= $.extend({}, Tooltip
.Default
, {
30 template
: '<div class="popover" role="tooltip">'
31 + '<h3 class="popover-title"></h3>'
32 + '<div class="popover-content"></div></div>'
35 const DefaultType
= $.extend({}, Tooltip
.DefaultType
, {
36 content
: '(string|element|function)'
45 TITLE
: '.popover-title',
46 CONTENT
: '.popover-content'
50 HIDE
: `hide${EVENT_KEY}`,
51 HIDDEN
: `hidden${EVENT_KEY}`,
52 SHOW
: `show${EVENT_KEY}`,
53 SHOWN
: `shown${EVENT_KEY}`,
54 INSERTED
: `inserted${EVENT_KEY}`,
55 CLICK
: `click${EVENT_KEY}`,
56 FOCUSIN
: `focusin${EVENT_KEY}`,
57 FOCUSOUT
: `focusout${EVENT_KEY}`,
58 MOUSEENTER
: `mouseenter${EVENT_KEY}`,
59 MOUSELEAVE
: `mouseleave${EVENT_KEY}`
64 * ------------------------------------------------------------------------
66 * ------------------------------------------------------------------------
69 class Popover
extends Tooltip
{
74 static get VERSION() {
78 static get Default() {
86 static get DATA_KEY() {
94 static get EVENT_KEY() {
98 static get DefaultType() {
106 return this.getTitle() || this._getContent()
110 return this.tip
= this.tip
|| $(this.config
.template
)[0]
114 const $tip
= $(this.getTipElement())
116 // we use append for html objects to maintain js events
117 this.setElementContent($tip
.find(Selector
.TITLE
), this.getTitle())
118 this.setElementContent($tip
.find(Selector
.CONTENT
), this._getContent())
120 $tip
.removeClass(`${ClassName.FADE} ${ClassName.SHOW}`)
128 return this.element
.getAttribute('data-content')
129 || (typeof this.config
.content
=== 'function' ?
130 this.config
.content
.call(this.element
) :
137 static _jQueryInterface(config
) {
138 return this.each(function () {
139 let data
= $(this).data(DATA_KEY
)
140 const _config
= typeof config
=== 'object' ? config
: null
142 if (!data
&& /destroy|hide/.test(config
)) {
147 data
= new Popover(this, _config
)
148 $(this).data(DATA_KEY
, data
)
151 if (typeof config
=== 'string') {
152 if (data
[config
] === undefined) {
153 throw new Error(`No method named "${config}"`)
163 * ------------------------------------------------------------------------
165 * ------------------------------------------------------------------------
168 $.fn
[NAME
] = Popover
._jQueryInterface
169 $.fn
[NAME
].Constructor
= Popover
170 $.fn
[NAME
].noConflict = function () {
171 $.fn
[NAME
] = JQUERY_NO_CONFLICT
172 return Popover
._jQueryInterface
179 export default Popover