Popovers
Matsalwa na swikombiso swo engetela ti-popover ta Bootstrap, ku fana na leti kumekaka eka iOS, eka elemente yihi na yihi eka sayiti ya wena.
Nkatsakanyo
Swilo leswi u faneleke u swi tiva loko u tirhisa plugin ya popover:
- Popovers yi titshege hi layiburari ya 3rd party Popper eka xiyimo. U fanele ku katsa popper.min.js emahlweni ka bootstrap.js kumbe u tirhisa
bootstrap.bundle.min.js
/bootstrap.bundle.js
leyi nga na Popper leswaku ti-popovers ti tirha! - Popovers yi lava plugin ya tooltip tanihi ku titshega.
- Ti-popovers i ti-opt-in hikwalaho ka swivangelo swa matirhelo, hikwalaho u fanele u ti sungula hi wexe .
- Zero-length
title
nacontent
values a swi nge pfuki swi kombisi popover. - Boxa
container: 'body'
ku papalata swiphiqo swa ku hundzuluxela eka swiphemu leswi rharhanganeke swinene (ku fana na mintlawa ya hina ya ku nghenisa, mintlawa ya swikomba-nkarhi, na swin’wana). - Ku hlohlotela ti-popovers eka swiaki leswi fihliweke a swi nge tirhi.
- Popovers for
.disabled
kumbedisabled
ti elements tifanele ku pfuriwa eka element ya wrapper. - Loko yi hlohleteriwa kusuka eka ti anchors leti phutselaka eka milayeni yotala, ti popovers titava tiri exikarhi exikarhi ka ku anama hinkwako ka ti anchors. Tirhisa
.text-nowrap
eka s ya wena<a>
ku papalata mahanyelo lawa. - Ti popovers tifanele ku fihliwa loko ti elements ta tona leti fambelanaka tinga se susiwa eka DOM.
- Popovers yinga pfuriwa hiku khensa element endzeni ka shadow DOM.
prefers-reduced-motion
xivutiso xa midiya. Vona
xiyenge xa ku famba loku hungutiweke xa matsalwa ya hina ya ku fikelela .
Tshama u ri karhi u hlaya ku vona ndlela leyi ti- popover ti tirhaka ha yona hi swikombiso swin’wana.
Xikombiso: Endla leswaku ti-popovers ti tirha hinkwako-nkwako
Ndlela yin’wana yo sungula ti-popover hinkwato eka tluka ku nga va ku ti hlawula hi data-bs-toggle
xihlawulekisi xa tona:
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl)
})
Xikombiso: Ku tirhisa container
nhlawulo
Loko u ri na switayele swin’wana eka elemente ya mutswari leswi kavanyetaka popover, u ta lava ku boxa ntolovelo container
leswaku HTML ya popover yi humelela endzeni ka elemente yoleyo ematshan’wini ya sweswo.
var popover = new bootstrap.Popover(document.querySelector('.example-popover'), {
container: 'body'
})
Xikombiso
<button type="button" class="btn btn-lg btn-danger" data-bs-toggle="popover" title="Popover title" data-bs-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
Tindlela ta mune
Ku ni swilo swa mune leswi u nga swi hlawulaka: leswi ringanisiweke ehenhla, exineneni, ehansi ni le ximatsi. Swiletelo swi kombisiwa hi xivoni loko u tirhisa Bootstrap eka RTL.
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="top" data-bs-content="Top popover">
Popover on top
</button>
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="right" data-bs-content="Right popover">
Popover on right
</button>
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="bottom" data-bs-content="Bottom popover">
Popover on bottom
</button>
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="left" data-bs-content="Left popover">
Popover on left
</button>
Dismiss eka ku click loku landzelaka
Tirhisa focus
xihlohloteri ku hlongola ti-popover eka ku tsindziyela loku landzelaka ka mutirhisi ka elemente yo hambana ku tlula elemente yo cinca-cinca.
Ku laveka ku fungha ko karhi eka ku hlongoriwa-eka-ku-click loku landzelaka
Ku kuma mahanyelo lamanene ya cross-browser na cross-platform, u fanele ku tirhisa <a>
thegi, ku nga ri <button>
thegi, naswona u fanele ku tlhela u katsa tabindex
xihlawulekisi.
<a tabindex="0" class="btn btn-lg btn-danger" role="button" data-bs-toggle="popover" data-bs-trigger="focus" title="Dismissible popover" data-bs-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</a>
var popover = new bootstrap.Popover(document.querySelector('.popover-dismiss'), {
trigger: 'focus'
})
Swiaki leswi lamaleke
Swiaki leswi nga na disabled
xihlawulekisi a swi tirhisani, leswi vulaka leswaku vatirhisi a va nge swi koti ku hover kumbe ku swi tsindziyela ku pfuxa popover (kumbe tooltip). Tanihi ndlela yo tshungula, u ta lava ku pfuxa popover ku suka eka xifunengeto <div>
kumbe <span>
, hi ndlela leyinene yi endliwe leswaku yi kongomisiwa eka khibhodi hi ku tirhisa tabindex="0"
.
Eka swihlohloteri swa popover leswi lamaleke, u nga ha tlhela u tsakela data-bs-trigger="hover focus"
leswaku popover yi humelela tanihi vuyelo bya xihatla bya xivono eka vatirhisi va wena tanihileswi va nga ha langutelaka ku tikhoma eka elemente leyi lamaleke.
<span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-content="Disabled popover">
<button class="btn btn-primary" type="button" disabled>Disabled button</button>
</span>
Sass
Swilo leswi cinca-cincaka
$popover-font-size: $font-size-sm;
$popover-bg: $white;
$popover-max-width: 276px;
$popover-border-width: $border-width;
$popover-border-color: rgba($black, .2);
$popover-border-radius: $border-radius-lg;
$popover-inner-border-radius: subtract($popover-border-radius, $popover-border-width);
$popover-box-shadow: $box-shadow;
$popover-header-bg: shade-color($popover-bg, 6%);
$popover-header-color: $headings-color;
$popover-header-padding-y: .5rem;
$popover-header-padding-x: $spacer;
$popover-body-color: $body-color;
$popover-body-padding-y: $spacer;
$popover-body-padding-x: $spacer;
$popover-arrow-width: 1rem;
$popover-arrow-height: .5rem;
$popover-arrow-color: $popover-bg;
$popover-arrow-outer-color: fade-in($popover-border-color, .05);
Matirhiselo
Endla leswaku ti-popovers ti tirha hi ku tirhisa JavaScript:
var exampleEl = document.getElementById('example')
var popover = new bootstrap.Popover(exampleEl, options)
Ku endla leswaku ti-popover ti tirha eka vatirhisi va khibhodi ni thekinoloji yo pfuneta
Ku pfumelela vatirhisi va khibhodi ku tirhisa ti-popover ta wena, u fanele ku ti engetela ntsena eka swiaki swa HTML leswi hi ntolovelo swi kongomisiweke eka khibhodi na ku tirhisana (ku fana na swihlanganisi kumbe vulawuri bya fomo). Hambileswi swiaki swa HTML swa ku tihlawulela (swo tanihi <span>
s) swi nga endliwaka swi kongomisiwa hi ku engetela tabindex="0"
xihlawulekisi, leswi swi ta engetela ku yima ka tithebhu loku nga ha hlundzukisaka ni ku pfilunganya eka swiaki leswi nga riki swa vuhlanganisi eka vatirhisi va khibhodi, naswona thekinoloji yo tala leyi pfunaka sweswi a yi tivisi swilo swa popover eka xiyimo lexi . Ku engetela kwalaho, u nga titshegi ntsena hi hover
tanihi xihlohloteri xa ti-popover ta wena, tanihi leswi leswi swi nga ta endla leswaku ti nga koteki ku ti pfuxa eka vatirhisi va khibhodi.
Hambileswi u nga nghenisaka HTML leyi fuweke, leyi hlelekeke eka ti-popovers hi html
nhlawulo, hi ringanyeta swinene leswaku u papalata ku engetela nhlayo leyi tlulaka mpimo ya swilo leswi nga endzeni. Ndlela leyi ti popovers ti tirhaka ha yona sweswi hileswaku, loko ti kombisiwile, leswi nga endzeni ka swona swi boheleriwe eka trigger element leyi nga na aria-describedby
attribute. Hikwalaho ka sweswo, hinkwaswo leswi nga endzeni ka popover swi ta tivisiwa eka vatirhisi va thekinoloji leyi pfunaka tanihi xirhendzevutana xin’we xo leha, lexi nga kavanyetiwiki.
Ku engetela kwalaho, hambi leswi swi kotekaka ku tlhela u katsa vulawuri byo tirhisana (ku fana na swiaki swa xivumbeko kumbe swihlanganisi) eka popover ya wena (hi ku engetela swiaki leswi eka allowList
ya swihlawulekisi leswi pfumeleriweke na tithegi), tiva leswaku sweswi popover a yi lawuli ku landzelelana ka ku kongomisa ka khibhodi. Loko mutirhisi wa khibhodi a pfula popover, ku kongomisa ku tshama eka elemente leyi pfuxaka, naswona tanihi leswi popover hi ntolovelo yi nga hatliki ku landzelela trigger eka xivumbeko xa tsalwa, a ku na xitiyisekiso xa leswaku ku ya emahlweni/ku tshikilelaTAByi ta yisa mutirhisi wa khibhodi eka popover hi yoxe. Hi ku komisa, ku engetela ntsena vulawuri byo tirhisana eka popover swi nga ha endla leswaku vulawuri lebyi byi nga fikeleleki/ byi nga tirhisiwi eka vatirhisi va khibhodi na vatirhisi va thekinoloji yo pfuneta, kumbe hi mpimo lowutsongo swi endla leswaku ku va na oda ya ku kongomisa hi ku angarhela leyi nga twisisekiki. Eka swiyimo leswi, anakanya hi ku tirhisa mbulavurisano wa modal ematshan’wini ya sweswo.
Swihlawulekisi
Swihlawulekisi swi nga hundzisiwa hi ku tirhisa swihlawulekisi swa data kumbe JavaScript. Eka swihlawulekisi swa datha, engetela vito ra xihlawuhlawu eka data-bs-
, tanihi le ka data-bs-animation=""
. Tiyisisa leswaku u cinca muxaka wa xiyimo xa vito ra xihlawulekisi ku suka eka camelCase ku ya eka kebab-case loko u hundzisa swihlawulekisi hi ku tirhisa swihlawulekisi swa data. Hi xikombiso, ematshan’weni yo tirhisa data-bs-customClass="beautifier"
, tirhisa data-bs-custom-class="beautifier"
.
sanitize
,
sanitizeFn
, na
allowList
swihlawulekisi a swi nge nyikiwi hi ku tirhisa swihlawulekisi swa data.
Vito | Muxaka | Ku tlula | Nhlamuselo |
---|---|---|---|
animation |
xitsonga xitsonga | true |
Tirhisa ku cinca ka CSS fade eka popover |
container |
ntambhu ya xirhendzevutani | xiaki xa | vunwa | false |
Ku engetela popover eka elemente yo karhi. Xikombiso: |
content |
ntambhu ya xirhendzevutani | xiaki xa | ntirho | '' |
Ntsengo wa nhundzu ya xiviri loko Loko ntirho wu nyikiwile, wu ta vitaniwa hi |
delay |
nomboro | nchumu | 0 |
Ku hlwela ku kombisa na ku tumbeta popover (ms) - a swi tirhi eka muxaka wa manual trigger Loko nomboro yi nyikiwile, ku hlwela ku tirhisiwa eka havumbirhi bya ku fihla/kombisa Xivumbeko xa nchumu i: |
html |
xitsonga xitsonga | false |
Nghenisa HTML eka popover. Loko ku ri mavunwa, innerText nhundzu yi ta tirhisiwa ku nghenisa nhundzu eka DOM. Tirhisa tsalwa loko u vilerisiwa hi nhlaselo wa XSS. |
placement |
ntambhu ya xirhendzevutani | ntirho | 'right' |
Ndlela yo veka popover - auto | ehenhla | ehansi | ximatsi | mfanelo. Loko ntirho wu tirhisiwa ku kumisisa ku vekiwa, wu vitaniwa hi popover DOM node tanihi argument ya wona yo sungula na triggering element DOM node tanihi ya vumbirhi. Mongo |
selector |
ntambhu ya xirhendzevutani | vunwa | false |
Loko ku nyikiwile xihlawulekisi, swilo swa popover swi ta nyikiwa swikongomelo leswi boxiweke. Hi ku tirhisa, leswi swi tirhisiwa ku endla leswaku nhundzu ya HTML leyi cinca-cincaka yi va na ti-popover leti engeteriweke. Vona leswi ni xikombiso lexi dyondzisaka . |
template |
ntambu | '<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>' |
Base HTML ku tirhisa loko u endla popover. Popover's Popover's
Xiphemu xa le handle xa xifunengeto xi fanele ku va na |
title |
ntambhu ya xirhendzevutani | xiaki xa | ntirho | '' |
Nhlayo ya xihloko xa xiviri loko Loko ntirho wu nyikiwile, wu ta vitaniwa hi |
trigger |
ntambu | 'click' |
Ndlela leyi popover yi sungulaka ha yona - click | hover | ku kongomisa | manyuwali. U nga ha hundza swihlohloteri swo tala; va hambanise hi xivandla. manual a yi nge hlanganisiwi ni xihlohloteri xin’wana. |
fallbackPlacements |
array ya xirhendzevutani | ['top', 'right', 'bottom', 'left'] |
Hlamusela swivandla swa fallback hi ku nyika nxaxamelo wa swivandla eka array (hi ku landzelelana ka ku tsakela). Ku kuma vuxokoxoko byo tala languta eka Popper's behavior docs |
boundary |
ntambhu ya xirhendzevutani | nchumu | 'clippingParents' |
Ndzilakano wa xipimelo xa ku khuluka ka popover (wu tirha ntsena eka mucinci wa Popper wa preventOverflow). Hi ku tiyimisela i 'clippingParents' naswona yi nga amukela xikombo xa HTMLElement (hi ku tirhisa JavaScript ntsena). Ku kuma vuxokoxoko byo tala languta eka Popper's detectOverflow docs . |
customClass |
ntambhu ya xirhendzevutani | ntirho | '' |
Engetela titlilasi eka popover loko yi kombisiwa. Xiya leswaku titlilasi leti ti ta engeteriwa ku engetela eka titlilasi tihi na tihi leti boxiweke eka xifaniso. Ku engetela titlilasi to tala, ti hambanise hi swivandla: U nga ha tlhela u hundzisela ntirho lowu faneleke ku vuyisa ntambhu yin’we leyi nga na mavito ya titlilasi yo engetela. |
sanitize |
xitsonga xitsonga | true |
Endla leswaku ku tirhisiwa kumbe ku tshikisa ku basisiwa. If activated 'template' , 'content' na 'title' swihlawulekisi swi ta sanitized. Vona xiyenge xa sanitizer eka matsalwa ya hina ya JavaScript . |
allowList |
nchumu | Nhlayo ya xiviri | Nchumu lowu nga na swihlawulekisi leswi pfumeleriweke na tithegi |
sanitizeFn |
null | ntirho | null |
Laha unga phakela ntirho wa wena wa sanitize. Leswi swinga pfuna loko u tsakela ku tirhisa layiburari leyi tinyiketeleke ku endla ku basisiwa. |
offset |
xirhendzevutani | ntambhu ya xirhendzevutani | ntirho | [0, 8] |
Offset ya popover loko yi pimanisiwa na target ya yona. U nga hundza ntambhu eka swihlawulekisi swa datha hi mimpimo leyi hambanisiweke hi khoma ku fana na: Loko ntirho wu tirhisiwa ku kumisisa offset, wu vitaniwa hi nchumu lowu nga na popper placement, reference, na popper rects tani hi argument ya wona yo sungula. Node ya DOM ya elemente leyi hlohlotelaka yi hundziseriwa tanihi argument ya vumbirhi. Ntirho wu fanele ku vuyisa array leyi nga na tinomboro timbirhi: . Ku kuma vuxokoxoko byo tala languta eka Popper's offset docs . |
popperConfig |
null | nchumu | ntirho | null |
Ku cinca xivumbeko xa Popper xa xiviri xa Bootstrap, vona xivumbeko xa Popper . Loko ntirho wu tirhisiwa ku tumbuluxa xivumbeko xa Popper, wu vitaniwa hi nchumu lowu nga na xivumbeko xa Popper xa xiviri xa Bootstrap. Swi ku pfuna ku tirhisa ni ku hlanganisa leswi nga riki swa xiviri ni xivumbeko xa wena. Ntirho wu fanele ku vuyisa nchumu wa vuhlanganisi bya Popper. |
Swihlawulekisi swa data swa ti-popover ta munhu hi xiyexe
Swihlawulekisi swa ti popovers ha yin’we yin’we tinga boxiwile hindlela yin’wana hiku tirhisa swihlawulekisi swa data, tani hileswi swinga hlamuseriwa laha henhla.
Ku tirhisa ntirho napopperConfig
var popover = new bootstrap.Popover(element, {
popperConfig: function (defaultBsPopperConfig) {
// var newPopperConfig = {...}
// use defaultBsPopperConfig if needed...
// return newPopperConfig
}
})
Maendlelo
Maendlelo ya asynchronous na ku cinca
Maendlelo hinkwawo ya API i ya asynchronous naswona ya sungula ku cinca . Va tlhelela eka mufoyini hi ku hatlisa loko ku cinca ku sungurile kambe ku nga si hela . Ku engetela kwalaho, ku vitaniwa ka ndlela eka xiphemu lexi cincaka ku ta honisiwa .
Vona matsalwa ya hina ya JavaScript ku kuma vuxokoxoko byo tala .
kombisa
Ku paluxa popover ya elemente. Ku tlhelela eka mufoyini loko popover yi nga si kombisiwa hakunene (i.e. shown.bs.popover
xiendlakalo xi nga si humelela). Leswi swi tekiwa tanihi ku hlohlotela “manual” ka popover. Ti-popover leti nhloko-mhaka ya tona ni leswi nga endzeni ka tona swi nga zero-length a swi si tshama swi kombisiwa.
myPopover.show()
tumbela
Ku tumbeta popover ya elemente. Ku tlhelela eka mufoyini loko popover yi nga si fihliwa hakunene (i.e. hidden.bs.popover
xiendlakalo xi nga si humelela). Leswi swi tekiwa tanihi ku hlohlotela “manual” ka popover.
myPopover.hide()
ku cinca-cinca
Ku cinca-cinca popover ya elemente. Ku tlhelela eka mufoyini loko popover yi nga si kombisiwa hakunene kumbe ku tumbetiwa (i.e. emahlweni ka ku humelela shown.bs.popover
kumbe hidden.bs.popover
xiendlakalo). Leswi swi tekiwa tanihi ku hlohlotela “manual” ka popover.
myPopover.toggle()
lahla
Ku tumbeta no herisa popover ya elemente (Ku susa data leyi hlayisiweke eka elemente ya DOM). Popovers leyi tirhisaka delegation (leswi endliwaka hi ku tirhisa selector
option ) a yi nge herisiwi hi yoxe eka ti descendant trigger elements.
myPopover.dispose()
koteka
Swi nyika popover ya elemente vuswikoti byo kombisiwa. Popovers yi tirhisiwa hi ku tiyimisela.
myPopover.enable()
vulamari
Ku susa vuswikoti bya ku kombisiwa ka popover ya elemente. Popover yi ta kota ku kombisiwa ntsena loko yi tlhela yi tirhisiwa.
myPopover.disable()
toggleYi pfuriwile
Toggles vuswikoti bya leswaku popover ya element yi kombisiwa kumbe ku fihliwa.
myPopover.toggleEnabled()
pfuxeta
Ku pfuxeta xiyimo xa popover ya elemente.
myPopover.update()
getXikombiso
Ndlela ya static leyi ku pfumelelaka ku kuma xikombiso xa popover lexi fambelanaka na elemente ya DOM
var exampleTriggerEl = document.getElementById('example')
var popover = bootstrap.Popover.getInstance(exampleTriggerEl) // Returns a Bootstrap popover instance
kumaKumbeEndlaXikombiso
Ndlela ya static leyi ku pfumelelaka ku kuma xikombiso xa popover lexi fambelanaka na elemente ya DOM, kumbe ku tumbuluxa leyintshwa loko ko tshuka ku nga sunguriwanga
var exampleTriggerEl = document.getElementById('example')
var popover = bootstrap.Popover.getOrCreateInstance(exampleTriggerEl) // Returns a Bootstrap popover instance
Swiendlakalo
Muxaka wa xiendlakalo | Nhlamuselo |
---|---|
kombisa.bs.vusiwana | Xiendlakalo lexi xi pfurha hi ku hatlisa loko ku show vitaniwa ndlela ya xikombiso. |
swi kombisiwile.bs.vusiwana | Xiendlakalo lexi xi hlongoriwa loko popover yi endliwile yi vonaka eka mutirhisi (yi ta rindza ku cinca ka CSS ku hela). |
tumbeta.bs.vusiwana | Xiendlakalo lexi xi duvuriwa hi ku hatlisa loko ndlela ya hide xikombiso yi vitaniwile. |
swi fihliwile.bs.vusiwana | Xiendlakalo lexi xi duvuriwa loko popover yi hetile ku tumbetiwa eka mutirhisi (yi ta rindza ku cinca ka CSS ku hela). |
ku nghenisiwile.bs.vusiwana | Xiendlakalo lexi xi hlongoriwa endzhaku ka show.bs.popover xiendlakalo loko xifaniso xa popover xi engeteriwile eka DOM. |
var myPopoverTrigger = document.getElementById('myPopover')
myPopoverTrigger.addEventListener('hidden.bs.popover', function () {
// do something...
})