Popovers
Faʻamaumauga ma faʻataʻitaʻiga mo le faʻaopoopoina o Bootstrap popovers, pei o loʻo maua i iOS, i soʻo se elemene i luga o lau 'upega tafaʻilagi.
Vaaiga lautele
Mea e iloa pe a faʻaaogaina le popover plugin:
- Popovers fa'alagolago ile faletusi lona tolu Popper mo le fa'atulagaina. E tatau ona e aofia ai popper.min.js i luma o le bootstrap.js poʻo le faʻaoga
bootstrap.bundle.min.js
/bootstrap.bundle.js
o loʻo i ai Popper ina ia mafai ai ona galue popovers! - Popovers manaʻomia le meafaigaluega faʻapipiʻi e fai ma faʻalagolago.
- Popovers e filifili i totonu mo mafuaʻaga o faʻatinoga, o lea e tatau ai ona e amataina oe lava ia .
- Ole umi ole umi
title
macontent
tau o le a le fa'aalia se popover. - Fa'ama'oti
container: 'body'
e 'alofia ai le fa'atupuina o fa'afitauli i vaega e sili atu ona lavelave (pei o tatou vaega fa'aoga, vaega fa'amau, ma isi). - O le faʻaosoina o popovers i elemene natia o le a le aoga.
- Popovers mo
.disabled
po'odisabled
elemene e tatau ona fa'aoso i luga o se elemene afifi. - A fa'aoso mai taula e afifi i luga o le tele o laina, popovers o le a totonugalemu i le va o taula' lautele lautele. Fa'aoga
.text-nowrap
i lou<a>
s e aloese ai mai lenei amio. - Popovers e tatau ona natia aʻo leʻi aveesea a latou elemene tutusa mai le DOM.
- Popovers e mafai ona faʻaosoina faʻafetai i se elemene i totonu o se ata lafoia DOM.
prefers-reduced-motion
aufaasālalau. Va'ai le vaega
fa'aitiitiga fa'aitiitiga oa matou pepa fa'aoga avanoa .
Fa'aauau le faitau e va'ai pe fa'afefea ona galue popovers ma nisi fa'ata'ita'iga.
Fa'ata'ita'iga: Fa'aaga popovers i so'o se mea
O se tasi o auala e amata ai popovers uma i luga o se itulau o le filifilia lea e ala i o latou data-bs-toggle
uiga:
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl)
})
Faataitaiga: Faʻaaogaina le container
filifiliga
A iai ni au sitaili i luga o se elemene matua e faʻalavelave i se popover, e te manaʻo e faʻamaonia se aganuʻu container
ina ia faʻaalia le HTML o le popover i totonu o lena elemene nai lo.
var popover = new bootstrap.Popover(document.querySelector('.example-popover'), {
container: 'body'
})
Faataitaiga
<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>
Fa ituala
E fa filifiliga o lo'o avanoa: luga, taumatau, pito i lalo, ma agavale fa'aoga. E fa'aata fa'atonuga pe a fa'aaoga Bootstrap ile 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>
Fa'ate'a ile isi kiliki
Fa'aaoga le focus
fa'aoso e fa'ate'a ai popovers i le isi kiliki a le tagata fa'aoga o se elemene ese nai lo le elemene sosolo.
Fa'ailoga fa'apitoa e mana'omia mo le fa'ate'aina-i le isi-kiliki
Mo le sa'o-su'esu'e ma le koluse-platform amio, e tatau ona e fa'aogaina le <a>
pine, ae le o le <button>
pine, ma e tatau foi ona e aofia ai se tabindex
uiga.
<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'
})
Elemene le atoatoa
O elemene e iai le disabled
uiga e le fegalegaleai, o lona uiga e le mafai e tagata faʻaoga ona faʻafefe pe kiliki i latou e faʻaoso ai se popover (poʻo se meafaigaluega). I le avea ai o se fofo, e te manaʻo e faʻaosoina le popover mai se afifi <div>
poʻo <span>
, faʻaoga lelei le keyboard-faʻaogaina le tabindex="0"
.
Mo fa'aoso popover fa'aletonu, atonu e te mana'o data-bs-trigger="hover focus"
fo'i ina ia fa'aalia le popover o se fa'aaliga va'aia vave i au tagata fa'aoga ona latou te le o fa'amoemoe e kiliki i luga o se elemene fa'aletonu.
<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
Fuafuaga
$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);
Fa'aoga
Fa'amalo popovers e ala i le JavaScript:
var exampleEl = document.getElementById('example')
var popover = new bootstrap.Popover(exampleEl, options)
O le fa'aogaina o popovers e aoga mo keyboard ma fa'aoga tekonolosi fesoasoani
Ina ia faʻatagaina tagata faʻaoga keyboard e faʻagaoioia au popovers, e tatau ona e faʻaopoopoina i latou i elemene HTML e masani ona taulaʻi ma fefaʻasoaaʻi (pei o fesoʻotaʻiga poʻo faʻatonuga). E ui lava e mafai ona faʻaogaina elemene HTML (e pei o <span>
le s) e ala i le faʻaopoopoina o le tabindex="0"
uiga, o le a faʻaopoopoina faʻalavelave faʻalavelave ma fenumiai taofi i luga o elemene e le o fesoʻotaʻi mo tagata faʻaoga keyboard, ma o le tele o tekinolosi fesoasoani i le taimi nei e le faʻasalalau atu mea o le popover i lenei tulaga. . E le gata i lea, aua le faʻalagolago naʻo hover
le faʻaosoina o au popovers, aua o le a le mafai ai ona faʻaosoina mo tagata faʻaoga keyboard.
E ui lava e mafai ona e faʻaofiina le HTML faʻamaualuga, faʻatulagaina i popovers ma le html
filifiliga, matou te fautuaina malosi e te aloese mai le faʻaopoopoina o le tele o mea. O le auala o loʻo galue ai popovers i le taimi nei, o le taimi lava e faʻaalia ai, o latou anotusi o loʻo nonoa i le elemene faʻaoso ma le aria-describedby
uiga. O le i'uga, o le atoaga o mea o lo'o i totonu o le popover o le a fa'asalalau atu i tagata fa'aoga tekonolosi fesoasoani e pei o se vaitafe umi e le motusia.
E le gata i lea, e ui lava e mafai ona aofia ai le faʻaogaina o fesoʻotaʻiga (e pei o elemene poʻo soʻotaga) i lau popover (e ala i le faʻaopoopoina o nei elemene i allowList
uiga faʻatagaina ma pine), ia e nofouta o le taimi nei e le o pulea e le popover le faʻatonuga o le keyboard. Pe a tatalaina e le tagata faʻaoga keyboard se popover, e tumau le taulaʻi i le elemene faʻaoso, ma talu ai e masani ona le vave mulimuli le popover i le faʻaoso i le fausaga o le pepa, e leai se faʻamaoniga o le agai i luma / oomi.TABo le a fa'aoso se tagata fa'aoga keyboard i totonu o le popover lava ia. I se faapuupuuga, na o le faʻaopoopoina o fesoʻotaʻiga faʻatonutonu i se popover e ono le mafai ai ona faʻaogaina / le mafai ona faʻaogaina nei faʻatonuga mo tagata faʻaoga keyboard ma tagata faʻaogaina tekinolosi fesoasoani, poʻo le mea sili ona itiiti e faia mo se faʻatonuga le faʻaogaina atoa. I nei tulaga, mafaufau e fa'aaoga se fa'atalanoaga fa'apitoa.
Filifiliga
O filifiliga e mafai ona pasia e ala i faʻamatalaga uiga poʻo le JavaScript. Mo fa'amatalaga uiga, fa'aopoopo le igoa filifiliga i le data-bs-
, pei o le data-bs-animation=""
. Ia mautinoa e sui le ituaiga mataupu o le igoa filifiliga mai le camelCase i le kebab-case pe a pasia filifiliga e ala i faʻamatalaga uiga. Mo se faʻataʻitaʻiga, nai lo le faʻaaogaina data-bs-customClass="beautifier"
, faʻaaoga data-bs-custom-class="beautifier"
.
sanitize
,
sanitizeFn
, ma
allowList
filifiliga e fa'aoga ai uiga fa'amaumauga.
Igoa | Ituaiga | Fa'atonu | Fa'amatalaga |
---|---|---|---|
animation |
boolean | true |
Fa'aoga se suiga e mou atu CSS i le popover |
container |
manoa | elemene | pepelo | false |
Fa'aopoopo le popover i se elemene patino. Faataitaiga: |
content |
manoa | elemene | galuega faatino | '' |
Fa'aleaogaina mea taua pe afai Afai e tu'uina atu se galuega, o le a vala'au ma lona |
delay |
numera | mea faitino | 0 |
Fa'atuai ona fa'aali ma nana le popover (ms) - e le fa'atatau i le fa'ailoga tusi tusi Afai e tu'uina atu se numera, fa'atuai e fa'aoga i natia/fa'aali uma O le fausaga o mea faitino o le: |
html |
boolean | false |
Fa'aofi le HTML i totonu o le popover. Afai e sese, innerText o le a fa'aoga meatotino e fa'aofi ai mea i totonu ole DOM. Fa'aoga tusitusiga pe a e popole i osofa'iga a le XSS. |
placement |
manoa | galuega faatino | 'right' |
Fa'afefea ona fa'atulaga le popover - auto | pito i luga | lalo | agavale | tauagavale. Pe a faʻaaogaina se galuega e fuafua ai le tuʻuina, e taʻua i le popover DOM node e fai ma ana finauga muamua ma le elemene DOM node lona lua. Ua |
selector |
manoa | pepelo | false |
Afai e tu'uina atu se tagata filifilia, o mea fa'apipi'i o le a tu'uina atu i fa'amoemoe fa'apitoa. I le fa'ata'ita'iga, o lo'o fa'aaogaina e mafai ai ona fa'aopoopoina mea fa'apitoa HTML e fa'aopoopo ai popovers. Vaʻai i lenei mea ma se faʻataʻitaʻiga faʻamatalaga . |
template |
manoa | '<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>' |
Fa'avae HTML e fa'aoga pe a fai le popover. O le popover's O le popover's
O le elemene afifi pito i fafo e tatau ona i ai le |
title |
manoa | elemene | galuega faatino | '' |
Fa'aigoa fa'aigoa tau pe afai Afai e tu'uina atu se galuega, o le a vala'au ma lona |
trigger |
manoa | 'click' |
E fa'afefea ona fa'aoso popover - kiliki | lele | taula'i | tusi lesona. E mafai ona e pasia le tele o fa'aoso; tuueseese ma se avanoa. manual e le mafai ona tu'ufa'atasia ma se isi fa'aoso. |
fallbackPlacements |
fa'asologa | ['top', 'right', 'bottom', 'left'] |
Fa'amatala tulaga fa'afo'i i tua e ala i le tu'uina atu o se lisi o tu'uga i le fa'asologa (i le fa'asologa o mea e fiafia i ai). Mo nisi fa'amatalaga va'ai ile Popper's behavior docs |
boundary |
manoa | elemene | 'clippingParents' |
Fa'agata fa'amama le tuaoi o le popover (fa'atatau i le Popper's preventOverflow modifier). E le mafai 'clippingParents' ona talia ma e mafai ona talia se HTMLElement reference (e ala i le JavaScript). Mo nisi fa'amatalaga va'ai ile Popper's detectOverflow docs . |
customClass |
manoa | galuega faatino | '' |
Fa'aopoopo vasega ile popover pe a fa'aalia. Manatua o nei vasega o le a faʻaopoopoina i soʻo se vasega o loʻo faʻamaonia i le mamanu. Ina ia faaopoopo ni vasega se tele, tuueseese i avanoa: E mafai fo'i ona e pasia se galuega e tatau ona toe fa'afo'i ai se manoa e tasi e iai isi igoa o vasega. |
sanitize |
boolean | true |
Fa'amalo pe tape le fa'amama. Afai e fa'agaoioia 'template' , 'content' ma 'title' filifiliga o le a fa'amama. Va'ai le vaega sanitizer i la matou pepa JavaScript . |
allowList |
mea faitino | Tau fa'aletonu | Fa'ailoga o lo'o i ai uiga fa'atagaina ma fa'ailoga |
sanitizeFn |
null | galuega faatino | null |
O iinei e mafai ona e tuʻuina atu lau lava galuega faʻamamaina. E mafai ona aoga pe afai e te mana'o e fa'aoga se faletusi fa'apitoa e fa'atino ai le fa'amama. |
offset |
fa'asologa | manoa | galuega faatino | [0, 8] |
Offset o le popover e faatatau i lona sini. E mafai ona e pasiina se manoa i uiga fa'amaumauga ma fa'ailoga e vavae'ese koma e pei o: A fa'aoga se galuega e fa'atatau ai le fa'a'ese'ese, e ta'ua i se mea o lo'o i ai le fa'aogaina o le popper, le fa'asinomaga, ma le popper rects e fai ma ana finauga muamua. O le fa'aosoina elemene DOM node ua pasia e fai ma finauga lona lua. O le galuega e tatau ona toe faʻafoʻi se laina e lua numera: Mo nisi fa'amatalaga va'ai ile Popper's offset docs . |
popperConfig |
null | mea | galuega faatino | null |
Ina ia suia Bootstrap's default Popper config, vaai le faatulagaga a Popper . A faʻaaogaina se galuega e fai ai le Popper configuration, e valaʻau i se mea e aofia ai le faʻaogaina o le Popper configuration a le Bootstrap. E fesoasoani ia te oe e fa'aoga ma tu'ufa'atasia le mea e le mafai ona fai ma lau lava fa'atulagaga. Ole galuega e tatau ona toe faʻafoʻi se mea faʻatulagaina mo Popper. |
Fa'amatalaga uiga mo popovers ta'itasi
O filifiliga mo popovers ta'ito'atasi e mafai ona fa'amaonia e ala i le fa'aogaina o uiga fa'amaumauga, e pei ona fa'amatalaina i luga.
Fa'aaogaina galuega fa'atasi mapopperConfig
var popover = new bootstrap.Popover(element, {
popperConfig: function (defaultBsPopperConfig) {
// var newPopperConfig = {...}
// use defaultBsPopperConfig if needed...
// return newPopperConfig
}
})
Metotia
Metotia ma suiga e le tutusa
O metotia API uma e le fetaui ma amata se suiga . Latou te toe fo'i atu i le tagata telefoni i le taimi lava e amata ai le suiga ae le'i uma . E le gata i lea, o le a le amanaʻiaina se auala e valaʻau ai i se vaega o suiga .
fa'aali
Fa'aalia le popover o se elemene. Toe fo'i i le tagata vala'au a'o le'i fa'aalia le popover (fa'atusa a'o le'i tupu le shown.bs.popover
mea na tupu). E manatu lenei mea o se "manual" faʻaosoina o le popover. Popovers o latou igoa ma anotusi e leai uma le umi e le fa'aalia.
myPopover.show()
lalafi
Natia le popover o se elemene. Toe fo'i i le tagata vala'au a'o le'i natia le popover (fa'atusa a'o le'i tupu le hidden.bs.popover
mea na tupu). E manatu lenei mea o se "manual" faʻaosoina o le popover.
myPopover.hide()
fesuia'i
Su'e le fa'apipi'i o se elemene. Toe fo'i i le tagata vala'au a'o le'i fa'aalia pe natia le popover (fa'atusa a'o le'i tupu le shown.bs.popover
po'o le hidden.bs.popover
mea na tupu). E manatu lenei mea o se "manual" faʻaosoina o le popover.
myPopover.toggle()
lafoa'i
Natia ma fa'aumatia le popover o se elemene (Ave'ese fa'amaumauga o lo'o teuina ile elemene DOM). Popovers e fa'aogaina le tu'uina atu (lea e faia e fa'aaoga ai le selector
filifiliga ) e le mafai ona fa'aumatia ta'ito'atasi i elemene fa'aoso tupuaga.
myPopover.dispose()
mafai
Tuuina atu i le popover o se elemene le mafai ona faʻaalia. Popovers e mafai ona fa'aletonu.
myPopover.enable()
fa'aletonu
Aveese le avanoa e fa'aalia ai le popover o se elemene. Ole popover ole a mafai ona fa'aalia pe a toe fa'aagaina.
myPopover.disable()
ToggleEnabled
Fa'asolo le avanoa e fa'aalia pe natia ai le popover o se elemene.
myPopover.toggleEnabled()
fa'afouga
Fa'afou le tulaga o le popover o se elemene.
myPopover.update()
getInstance
Metotia static lea e mafai ai ona e maua le faʻataʻitaʻiga popover e fesoʻotaʻi ma se elemene DOM
var exampleTriggerEl = document.getElementById('example')
var popover = bootstrap.Popover.getInstance(exampleTriggerEl) // Returns a Bootstrap popover instance
getOrCreateInstance
Metotia static lea e mafai ai e oe ona maua le popover faʻataʻitaʻiga e fesoʻotaʻi ma se elemene DOM, poʻo le fatuina o se mea fou i le tulaga e leʻi amataina.
var exampleTriggerEl = document.getElementById('example')
var popover = bootstrap.Popover.getOrCreateInstance(exampleTriggerEl) // Returns a Bootstrap popover instance
Mea na tutupu
Ituaiga mea na tupu | Fa'amatalaga |
---|---|
show.bs.popover | E mu vave lenei mea pe a show valaʻau le auala faʻataʻitaʻiga. |
fa'aalia.bs.popover | O lenei mea e tupu pe a faʻaalia le popover i le tagata faʻaoga (o le a faʻatali mo suiga CSS e maeʻa). |
hide.bs.popover | O lenei mea na tupu e faʻamalo vave pe a hide valaʻau le auala faʻataʻitaʻiga. |
hidden.bs.popover | O lenei mea e tupu pe a uma ona natia le popover mai le tagata faʻaoga (o le a faʻatali mo suiga CSS e maeʻa). |
inserted.bs.popover | O lenei mea na tupu e faʻamalo pe a maeʻa le show.bs.popover mea na tupu ina ua faʻapipiʻi le popover template i le DOM. |
var myPopoverTrigger = document.getElementById('myPopover')
myPopoverTrigger.addEventListener('hidden.bs.popover', function () {
// do something...
})