Mea faigaluega
Faʻamaumauga ma faʻataʻitaʻiga mo le faʻaopoopoina o tuʻufaʻatasiga Bootstrap meafaigaluega faʻatasi ma le CSS ma le JavaScript e faʻaaoga ai le CSS3 mo faʻafiafiaga ma faʻamaumauga-bs-uiga mo le teuina o igoa faʻapitonuʻu.
Vaaiga lautele
Mea e tatau ona iloa pe a faʻaaogaina le meafaigaluega faʻapipiʻi:
- Mea faigaluega 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 faʻaoga meafaigaluega! - O mea faigaluega e filifili i totonu mo mafuaʻaga o faʻatinoga, o lea e tatau ai ona e amataina oe lava ia .
- E le fa'aalia lava ni mea faigaluega e leai ni fa'ailoga umi.
- 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). - E le aoga le fa'aosoina o mea faigaluega i elemene natia.
- O mea faigaluega mo
.disabled
po'odisabled
elemene e tatau ona fa'aoso i luga o se elemene afifi. - A fa'aoso mai hyperlinks e tele laina, o le a fa'atotonugalemu mea faigaluega. Fa'aoga
white-space: nowrap;
i lou<a>
s e aloese ai mai lenei amio. - E tatau ona natia mea faigaluega a'o le'i aveesea a latou elemene tutusa mai le DOM.
- Tooltips 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 .
E maua uma na mea? Lelei, se'i o tatou va'ai pe fa'apefea ona latou galulue fa'atasi ma ni fa'ata'ita'iga.
Fa'ata'ita'iga: Fa'aaga mea faigaluega i so'o se mea
O se tasi o auala e amata ai meafaigaluega uma i luga o se itulau o le filifilia lea i latou data-bs-toggle
uiga:
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})
Faataitaiga
Fa'apa i luga o so'oga o lo'o i lalo e va'ai i mea faigaluega:
Fa'amatalaga o lo'o tu'u iai e fa'aalia ai nisi o feso'ota'iga fa'atasi ma mea faigaluega. O lea ua na'o le fa'atumu, leai se fasioti tagata. O mea o lo'o tu'uina iinei e fa'atusa ai le iai o tusitusiga moni . Ma o na mea uma e naʻo le tuʻuina atu ia te oe o se manatu pe faʻapefea ona foliga meafaigaluega pe a faʻaaogaina i tulaga moni o le lalolagi. Fa'amoemoe la ua e va'ai nei pe fa'apefea ona galue nei mea faigaluega i luga o so'otaga i le fa'atinoga, pe a e fa'aogaina i luga o lau lava saite po'o le poloketi.
Fa'ae'e i luga o fa'amau i lalo e va'ai ai fa'atonuga meafaigaluega e fa: luga, taumatau, lalo, ma le agavale. E fa'aata fa'atonuga pe a fa'aaoga Bootstrap ile RTL.
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="Tooltip on top">
Tooltip on top
</button>
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="right" title="Tooltip on right">
Tooltip on right
</button>
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Tooltip on bottom">
Tooltip on bottom
</button>
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="left" title="Tooltip on left">
Tooltip on left
</button>
Ma faʻatasi ai ma le HTML masani faʻaopoopo:
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-html="true" title="<em>Tooltip</em> <u>with</u> <b>HTML</b>">
Tooltip with HTML
</button>
Faatasi ai ma se SVG:
Sass
Fuafuaga
$tooltip-font-size: $font-size-sm;
$tooltip-max-width: 200px;
$tooltip-color: $white;
$tooltip-bg: $black;
$tooltip-border-radius: $border-radius;
$tooltip-opacity: .9;
$tooltip-padding-y: $spacer * .25;
$tooltip-padding-x: $spacer * .5;
$tooltip-margin: 0;
$tooltip-arrow-width: .8rem;
$tooltip-arrow-height: .4rem;
$tooltip-arrow-color: $tooltip-bg;
Fa'aoga
O le tooltip plugin e fa'atupuina ai mea ma fa'ailoga pe a mana'omia, ma e le mafai ona tu'u meafaigaluega pe a mae'a a latou elemene fa'aoso.
Fa'aoso le mea faigaluega e ala ile JavaScript:
var exampleEl = document.getElementById('example')
var tooltip = new bootstrap.Tooltip(exampleEl, options)
Taumasua auto
mascroll
Ole tulaga ole Tooltip e taumafai e sui otometi pe a iai pe fiafia ile atigipusa matua ile matou , ae o lo'o tumau pea le tulaga o le tu'uga muamua. Ina ia foia lenei mea, seti le filifiliga (mo le faʻaoga suiga e faʻaaoga ai le filifiliga) i soʻo se HTMLElement e faʻamalo ai le tau le aoga, , e pei o le :overflow: auto
overflow: scroll
.table-responsive
boundary
popperConfig
'clippingParents'
document.body
var exampleEl = document.getElementById('example')
var tooltip = new bootstrap.Tooltip(exampleEl, {
boundary: document.body // or document.querySelector('#boundary')
})
Fa'ailoga
Ole fa'ailoga mana'omia mo se mea faigaluega e na'o se data
uiga ma title
luga ole elemene HTML e te mana'o e maua se meafaigaluega. O le faʻailoga faʻatupuina o se meafaigaluega e faigofie tele, e ui lava e manaʻomia se tulaga (e ala i le faaletonu, seti i top
le plugin).
Fa'aoga meafaigaluega mo keyboard ma fa'aoga tekonolosi fesoasoani
E tatau ona e fa'aopoopo na'o mea faigaluega i elemene HTML e masani ona fa'aogaina le keyboard ma fegalegaleai (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 ai faʻalavelave faʻalavelave ma fenumiai taofi i luga o elemene e le fesoʻotaʻi mo tagata faʻaoga keyboard, ma o le tele o tekinolosi fesoasoani i le taimi nei e le o faʻalauiloaina le meafaigaluega i lenei tulaga. E le gata i lea, aua le fa'alagolago na'o hover
le fa'aosoina o lau meafaigaluega, aua o le a le mafai ai e au meafaigaluega ona fa'aosoina mo tagata fa'aoga keyboard.
<!-- HTML to write -->
<a href="#" data-bs-toggle="tooltip" title="Some tooltip text!">Hover over me</a>
<!-- Generated markup by the plugin -->
<div class="tooltip bs-tooltip-top" role="tooltip">
<div class="tooltip-arrow"></div>
<div class="tooltip-inner">
Some tooltip text!
</div>
</div>
Elemene le atoatoa
O elemene e iai le disabled
uiga e le fegalegaleai, o lona uiga e le mafai e tagata faʻaoga ona taulaʻi, faʻafefe, pe kiliki i latou e faʻaosoina ai se meafaigaluega (poʻo le popover). I le avea ai o se fofo, e te manaʻo e faʻaosoina le meafaigaluega mai se afifi <div>
poʻo <span>
, faʻaoga lelei le keyboard-faʻaoga e faʻaaoga ai le tabindex="0"
.
<span class="d-inline-block" tabindex="0" data-bs-toggle="tooltip" title="Disabled tooltip">
<button class="btn btn-primary" type="button" disabled>Disabled button</button>
</span>
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 mea faigaluega |
container |
manoa | elemene | pepelo | false |
Fa'apipi'i le mea faigaluega i se elemene fa'apitoa. Faataitaiga: |
delay |
numera | mea faitino | 0 |
Fa'atuai ona fa'aali ma nana le mea faigaluega (ms) - e le fa'atatau ile ituaiga fa'aoso 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'ataga le HTML i le mea faigaluega. Afai e sa'o, o fa'ailoga HTML o lo'o i totonu o meafaigaluega o le Fa'aoga tusitusiga pe a e popole i osofa'iga a le XSS. |
placement |
manoa | galuega faatino | 'top' |
Fa'afefea ona fa'atulaga le mea faigaluega - ta'avale | pito i luga | lalo | agavale | tauagavale. Pe a faʻaaogaina se galuega e fuafua ai le tuʻuina, e taʻua i le tooltip DOM node e fai ma ana finauga muamua ma le elemene DOM node lona lua. O |
selector |
manoa | pepelo | false |
Afai e tu'uina atu se tagata filifilia, o mea fa'aoga meafaigaluega o le a tu'uina atu i fa'amoemoega fa'apitoa. I le faʻataʻitaʻiga, o loʻo faʻaaogaina e faʻaoga ai foi meafaigaluega e faʻaopoopo atili ai elemene DOM ( jQuery.on lagolago). Vaʻai i lenei mea ma se faʻataʻitaʻiga faʻamatalaga . |
template |
manoa | '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' |
Fa'avae HTML e fa'aoga pe a fai le mea faigaluega. O mea faigaluega o le
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 | 'hover focus' |
E fa'afefea ona fa'aosoina meafaigaluega - kiliki | lele | taula'i | tusi lesona. E mafai ona e pasia le tele o fa'aoso; tuueseese ma se avanoa.
|
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 mea faigaluega (na'o 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 i le mea faigaluega 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' 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, 0] |
Fa'a'ese'ese ole mea faigaluega e fa'atatau ile fa'amoemoe. 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 le faʻaogaina o le Popper config a Bootstrap, vaʻai i 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 meafaigaluega ta'itasi
O filifiliga mo meafaigaluega 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 tooltip = new bootstrap.Tooltip(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 mea faigaluega o se elemene. Toe fo'i atu i le tagata vala'au a'o le'i fa'aalia moni mai le mea faigaluega (fa'atusa a'o le'i tupu le shown.bs.tooltip
mea na tupu). O lenei mea ua manatu o se "manual" faʻaosoina o le meafaigaluega. E le fa'aalia lava ni mea faigaluega e leai ni fa'ailoga umi.
tooltip.show()
lalafi
Natia le mea faigaluega o se elemene. Toe fo'i atu i le tagata vala'au a'o le'i natia le mea faigaluega (fa'atusa a'o le'i tupu le hidden.bs.tooltip
mea na tupu). O lenei mea ua manatu o se "manual" faʻaosoina o le meafaigaluega.
tooltip.hide()
fesuia'i
Su'e le pito meafaigaluega a se elemene. Toe fo'i i le tagata vala'au a'o le'i fa'aalia pe natia le mea faigaluega (fa'atusa a'o le'i tupu le shown.bs.tooltip
po'o le hidden.bs.tooltip
mea na tupu). O lenei mea ua manatu o se "manual" faʻaosoina o le meafaigaluega.
tooltip.toggle()
lafoa'i
Natia ma fa'aleagaina le mea faigaluega a le elemene (Ave'ese fa'amaumauga o lo'o teuina ile elemene DOM). Tooltips e fa'aogaina le tu'uina atu (lea e faia i le fa'aogaina o le selector
filifiliga ) e le mafai ona fa'aumatia ta'ito'atasi i elemene fa'aoso tupuaga.
tooltip.dispose()
mafai
E tu'uina atu i se mea e fa'aoga meafaigaluega e mafai ona fa'aalia. E mafai ona fa'aogaina mea faigaluega.
tooltip.enable()
fa'aletonu
Aveese le agava'a mo se mea faigaluega e fa'aalia. Fa'atoa mafai ona fa'aalia le mea faigaluega pe a toe fa'aagaina.
tooltip.disable()
ToggleEnabled
Fa'afeso'ota'i le agava'a mo se mea faigaluega e fa'aalia pe natia.
tooltip.toggleEnabled()
fa'afouga
Fa'afou le tulaga o se mea faigaluega a le elemene.
tooltip.update()
getInstance
Metotia static lea e mafai ai e oe ona maua le faʻataʻitaʻiga meafaigaluega e fesoʻotaʻi ma se elemene DOM
var exampleTriggerEl = document.getElementById('example')
var tooltip = bootstrap.Tooltip.getInstance(exampleTriggerEl) // Returns a Bootstrap tooltip instance
getOrCreateInstance
Metotia static lea e mafai ai e oe ona maua le faʻataʻitaʻiga meafaigaluega 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 tooltip = bootstrap.Tooltip.getOrCreateInstance(exampleTriggerEl) // Returns a Bootstrap tooltip instance
Mea na tutupu
Ituaiga mea na tupu | Fa'amatalaga |
---|---|
show.bs.tooltip |
E mu vave lenei mea pe a show valaʻau le auala faʻataʻitaʻiga. |
shown.bs.tooltip |
O lenei mea na tupu e faʻamalo pe a faʻaalia le meafaigaluega i le tagata faʻaoga (o le a faʻatali mo suiga CSS e maeʻa). |
hide.bs.tooltip |
O lenei mea na tupu e faʻamalo vave pe a hide valaʻau le auala faʻataʻitaʻiga. |
hidden.bs.tooltip |
O lenei mea e tupu pe a uma ona natia le meafaigaluega mai le tagata faʻaoga (o le a faʻatali mo suiga CSS e maeʻa). |
inserted.bs.tooltip |
O lenei mea na tupu e faʻamalo pe a maeʻa le show.bs.tooltip mea na tupu ina ua faʻaopoopo le faʻataʻitaʻiga meafaigaluega i le DOM. |
var myTooltipEl = document.getElementById('myTooltip')
var tooltip = new bootstrap.Tooltip(myTooltipEl)
myTooltipEl.addEventListener('hidden.bs.tooltip', function () {
// do something...
})
tooltip.hide()