mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
fix
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
:root {
|
||||
|
||||
}
|
||||
.popover {
|
||||
--gap: 10px;
|
||||
--popper-border-width: 1px;
|
||||
--popper-border-color: #ccc;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0 /* rtl:ignore */;
|
||||
z-index: 1070;
|
||||
display: block;
|
||||
font-family: inherit;
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
text-align: left;
|
||||
text-align: start;
|
||||
text-decoration: none;
|
||||
text-shadow: none;
|
||||
text-transform: none;
|
||||
letter-spacing: normal;
|
||||
word-break: normal;
|
||||
word-spacing: normal;
|
||||
white-space: normal;
|
||||
line-break: auto;
|
||||
font-size: var(--popper-font-size);
|
||||
word-wrap: break-word;
|
||||
background-color: transparent;
|
||||
background-clip: padding-box;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
.popover .popover-arrow {
|
||||
|
||||
}
|
||||
|
||||
.popover-header:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.popover-content {
|
||||
border-radius: 3px;
|
||||
overflow: hidden;
|
||||
max-width: 200px;
|
||||
padding: 0;
|
||||
color: var(--popper-color);
|
||||
text-align: center;
|
||||
background-color: var(--popper-content-color);
|
||||
border: var(--popper-border-width) solid var(--popper-border-color);
|
||||
box-shadow: 0px 0px 5px -1px var(--popper-border-color);
|
||||
}
|
||||
.popover-header {
|
||||
padding: calc(var(--gap) / 2) calc(var(--gap));
|
||||
margin-bottom: 0;
|
||||
font-size: 1em;
|
||||
background-color: #f0f0f0;
|
||||
border-bottom: var(--popper-border-width) solid var(--popper-border-color);
|
||||
border-radius: 0;
|
||||
}
|
||||
.popover-body {
|
||||
padding: calc(var(--gap) / 2) calc(var(--gap));
|
||||
background-color: var(--popper-body-content-color);
|
||||
}
|
||||
.popover-footer:empty {
|
||||
display: none;
|
||||
}
|
||||
.popover-footer {
|
||||
padding: calc(var(--gap) / 2) calc(var(--gap));
|
||||
background-color: var(--popper-footer-content-color);
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
kit.PluginManager.register('popover',function(module, exports, require){
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v5.0.2): popover.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @type {kitTooltip} */
|
||||
var Tooltip = require('tooltip');
|
||||
|
||||
/** @type {kitBsCore} */
|
||||
var bsCore = require('bsCore');
|
||||
|
||||
var { defineJQueryPlugin } = bsCore.util.index;
|
||||
var SelectorEngine = bsCore.dom.SelectorEngine;
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Constants
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const NAME = 'popover'
|
||||
const DATA_KEY = 'bs.popover'
|
||||
const EVENT_KEY = `.${DATA_KEY}`
|
||||
const CLASS_PREFIX = 'bs-popover'
|
||||
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
|
||||
|
||||
const Default = {
|
||||
...Tooltip.Default,
|
||||
placement: 'right',
|
||||
offset: [0, 0],
|
||||
trigger: 'click',
|
||||
content: '',
|
||||
template: '<div class="popover" role="tooltip">' +
|
||||
'<div class="popover-arrow" data-popper-arrow="true"></div>' +
|
||||
'<div class="popover-content">' +
|
||||
'<h3 class="popover-header"></h3>' +
|
||||
'<div class="popover-body"></div>' +
|
||||
'<div class="popover-footer"></div>' +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
}
|
||||
|
||||
const DefaultType = {
|
||||
...Tooltip.DefaultType,
|
||||
content: '(string|element|function)'
|
||||
}
|
||||
|
||||
const Event = {
|
||||
HIDE: `hide${EVENT_KEY}`,
|
||||
HIDDEN: `hidden${EVENT_KEY}`,
|
||||
SHOW: `show${EVENT_KEY}`,
|
||||
SHOWN: `shown${EVENT_KEY}`,
|
||||
INSERTED: `inserted${EVENT_KEY}`,
|
||||
CLICK: `click${EVENT_KEY}`,
|
||||
FOCUSIN: `focusin${EVENT_KEY}`,
|
||||
FOCUSOUT: `focusout${EVENT_KEY}`,
|
||||
MOUSEENTER: `mouseenter${EVENT_KEY}`,
|
||||
MOUSELEAVE: `mouseleave${EVENT_KEY}`
|
||||
}
|
||||
|
||||
const CLASS_NAME_FADE = 'fade'
|
||||
const CLASS_NAME_SHOW = 'show'
|
||||
|
||||
const SELECTOR_TITLE = '.popover-header'
|
||||
const SELECTOR_CONTENT = '.popover-body'
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Class Definition
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
/** @class kitPopover */
|
||||
class Popover extends Tooltip {
|
||||
// Getters
|
||||
|
||||
static get Default() {
|
||||
return Default
|
||||
}
|
||||
|
||||
static get NAME() {
|
||||
return NAME
|
||||
}
|
||||
|
||||
static get Event() {
|
||||
return Event
|
||||
}
|
||||
|
||||
static get DefaultType() {
|
||||
return DefaultType
|
||||
}
|
||||
|
||||
// Overrides
|
||||
|
||||
isWithContent() {
|
||||
return this.getTitle() || this._getContent()
|
||||
}
|
||||
|
||||
getTipElement() {
|
||||
if (this.tip) {
|
||||
return this.tip
|
||||
}
|
||||
|
||||
this.tip = super.getTipElement()
|
||||
|
||||
if (!this.getTitle()) {
|
||||
SelectorEngine.findOne(SELECTOR_TITLE, this.tip).remove()
|
||||
}
|
||||
|
||||
if (!this._getContent()) {
|
||||
SelectorEngine.findOne(SELECTOR_CONTENT, this.tip).remove()
|
||||
}
|
||||
|
||||
return this.tip
|
||||
}
|
||||
|
||||
setContent() {
|
||||
const tip = this.getTipElement()
|
||||
|
||||
// we use append for html objects to maintain js events
|
||||
this.setElementContent(SelectorEngine.findOne(SELECTOR_TITLE, tip), this.getTitle())
|
||||
let content = this._getContent()
|
||||
if (typeof content === 'function') {
|
||||
content = content.call(this._element)
|
||||
}
|
||||
|
||||
this.setElementContent(SelectorEngine.findOne(SELECTOR_CONTENT, tip), content)
|
||||
|
||||
tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW)
|
||||
}
|
||||
|
||||
// Private
|
||||
|
||||
_addAttachmentClass(attachment) {
|
||||
this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`)
|
||||
}
|
||||
|
||||
_getContent() {
|
||||
return this._element.getAttribute('data-bs-content') || this._config.content
|
||||
}
|
||||
|
||||
_cleanTipClass() {
|
||||
const tip = this.getTipElement()
|
||||
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX)
|
||||
if (tabClass !== null && tabClass.length > 0) {
|
||||
tabClass.map(token => token.trim())
|
||||
.forEach(tClass => tip.classList.remove(tClass))
|
||||
}
|
||||
}
|
||||
|
||||
// Static
|
||||
|
||||
static jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
const data = Popover.getOrCreateInstance(this, config)
|
||||
|
||||
if (typeof config === 'string') {
|
||||
if (typeof data[config] === 'undefined') {
|
||||
throw new TypeError(`No method named "${config}"`)
|
||||
}
|
||||
|
||||
data[config]()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* jQuery
|
||||
* ------------------------------------------------------------------------
|
||||
* add .Popover to jQuery only if jQuery is present
|
||||
*/
|
||||
|
||||
defineJQueryPlugin(Popover)
|
||||
|
||||
module.exports = Popover;
|
||||
|
||||
return module.exports;
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user