Popovers ƒe amewo
Nuŋlɔɖiwo kple kpɔɖeŋuwo hena Bootstrap popovers, abe esiwo wokpɔ le iOS me ene, tsɔtsɔ kpe ɖe nu ɖesiaɖe si le wò nyatakakadzraɖoƒea ŋu.
Kpɔɖeŋunyagbɔgblɔ
Nusiwo wòle be nànya ne èle popover ƒe kpeɖeŋutɔa zãm:
- Popovers ɖoa ŋu ɖe 3rd party agbalẽdzraɖoƒe Popper ŋu hena ɖoƒeɖoɖo. Ele be nàde popper.min.js hafi bootstrap.js alo nàzã
bootstrap.bundle.min.js
/bootstrap.bundle.js
si me Popper le hafi popovers nawɔ dɔ! - Popovers hiã tooltip plugin abe nusi dzi woanɔ te ɖo ene.
- Popovers nye opt-in le dɔwɔwɔ ƒe susuwo ta, eyata ele be wò ŋutɔ nàdze wo gɔme .
- Zero-didime
title
kplecontent
asixɔxɔwo maɖe popover afia gbeɖe o. - Tsɔe
container: 'body'
be nàƒo asa na gbegɔmeɖeɖe ƒe kuxiwo le akpa siwo sesẽ wu me (abe míaƒe nyawo tsɔtsɔ de eme ƒe ƒuƒoƒowo, abɔta ƒe ƒuƒoƒowo, kple bubuawo ene). - Popovers ʋuʋu ɖe nu ɣaɣlawo dzi mawɔ dɔ o.
- Ele be woadze popovers na
.disabled
alodisabled
elements gɔme ɖe wrapper element dzi. - Ne wodze seke siwo xatsa ɖe fli geɖe dzi la, popovers la anɔ titina le sekeawo ƒe kekeme bliboa dome. Zã
.text-nowrap
le wò<a>
s dzi be nàƒo asa na nuwɔna sia. - Ele be woaɣla popovers hafi woaɖe woƒe akpa siwo sɔ kplii ɖa le DOM la me.
- Popovers ateŋu adze egɔme akpe ɖe element aɖe si le vɔvɔli DOM me ŋu.
prefers-reduced-motion
nyadzɔdzɔgblɔmɔnuwo ƒe nyabiasea dzi. Kpɔ
míaƒe mɔnukpɔkpɔwo ŋuti nuŋlɔɖiwo ƒe akpa si woɖe dzi kpɔtɔ .
Yi edzi nànɔ nu xlẽm be nàkpɔ alesi popovers wɔa dɔe kple kpɔɖeŋu aɖewo.
Kpɔɖeŋu: Na popovers nawɔ dɔ le afisiafi
Mɔ ɖeka si dzi woato adze popovers katã gɔme le axa aɖe dzi enye be woatia wo to woƒe data-bs-toggle
nɔnɔme nu:
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl)
})
Kpɔɖeŋu: container
Tiatiawɔblɔɖea zazã
Ne atsyã aɖewo le dzila ƒe akpa aɖe dzi siwo doa kplamatse popover la, àdi be yeagblɔ ɖoɖo aɖe container
ale be popover la ƒe HTML nadze le akpa ma me boŋ.
var popover = new bootstrap.Popover(document.querySelector('.example-popover'), {
container: 'body'
})
Kpɔɖeŋu
<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>
Mɔfiame ene
Tiatia ene li: etame, ɖusime, ete, kple miame. Mɔfiamewo dzena le ahuhɔ̃e me ne wole Bootstrap zãm le RTL me.
<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>
Ðe asi le eŋu le ʋuʋu si kplɔe ɖo me
Zã focus
trigger la tsɔ gbe popovers le zãla ƒe ʋuʋu si kplɔe ɖo le element si to vovo na toggle element la dzi.
Dzesi tɔxɛ aɖe hiã na dismiss-ne-next-click
Be nàkpɔ cross-browser kple cross-platform ƒe nuwɔna nyuie la, ele be nàzã <a>
tag la, ke menye tag la o <button>
, eye ele be nàde tabindex
nɔnɔme aɖe hã eme.
<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'
})
Nuwɔametɔwo ƒe akpawo
Elements kple disabled
attribute la menye interactive o, si fia be zãlawo mateŋu atsɔ asi aɖo wo dzi alo azi wo dzi atsɔ aʋã popover (alo tooltip) o. Abe egbɔkpɔnu ene la, àdi be yeaʋu popover la tso wrapper <div>
alo <span>
, si wowɔ nyuie be woate ŋu atsɔ keyboard-focusable zã tabindex="0"
.
Le popover triggers siwo nye nuwɔametɔwo gome la, àte ŋu alɔ̃ hã data-bs-trigger="hover focus"
be popover la nadze abe nukpɔkpɔ ƒe nyaŋuɖoɖo enumake ene na wò zãlawo elabena ɖewohĩ womakpɔ mɔ be yewoazi nuwɔametɔ ƒe akpa aɖe dzi o.
<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 ƒe nyawo
Nusiwo trɔna
$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);
Zãzã
Na popovers nawɔ dɔ to JavaScript dzi:
var exampleEl = document.getElementById('example')
var popover = new bootstrap.Popover(exampleEl, options)
Popovers wɔwɔ nawɔ dɔ na keyboard kple kpekpeɖeŋu mɔ̃ɖaŋununya zãlawo
Be nàɖe mɔ na keyboard zãlawo be woawɔ wò popovers la, ɖeko wòle be nàtsɔ wo akpe ɖe HTML ƒe akpa siwo te ŋu nɔa te ɖe keyboard dzi eye wowɔa nu aduadu le blema (abe kadodowo alo agbalẽvi dzi kpɔkpɔwo ene) la ŋu. Togbɔ be woateŋu ana HTML ƒe akpa siwo wowɔna le wo ɖokui si (abe <span>
s ene) nate ŋu alé ŋku ɖe wo ŋu to nɔnɔmea tsɔtsɔ kpee me hã la tabindex="0"
, esia atsɔ tab ƒe tɔtrɔ siwo ate ŋu ado dziku eye woatɔtɔ ame akpe ɖe nusiwo mewɔa dɔ kple wo nɔewo o ŋu na keyboard zãlawo, eye kpekpeɖeŋu mɔ̃ɖaŋununya akpa gãtɔ meɖea gbeƒã popover la ƒe nyawo le nɔnɔme sia me fifia o . Tsɔ kpe ɖe eŋu la, mègaɖo ŋu ɖe eŋu ɖeɖeko hover
be wòanye nusi aʋã wò popovers o, elabena esia ana be womate ŋu aʋã wo na keyboard zãlawo o.
Togbɔ be àte ŋu ade HTML si me kesinɔnuwo le, si woɖo ɖe ɖoɖo nu la popovers me kple html
tiatia la, míele aɖaŋu ɖom na wò vevie be nàƒo asa na nyatakaka gbogbo aɖewo tsɔtsɔ kpee. Alesi popovers wɔa dɔe fifia enye be, ne wonya ɖe wo fia ko la, woblaa woƒe emenyawo ɖe trigger element la ŋu kple aria-describedby
attribute la. Esia awɔe be woaɖe gbeƒã popover la me nyawo katã na mɔ̃ɖaŋununya siwo kpena ɖe ame ŋu zãlawo abe tɔsisi didi ɖeka si me womeɖea asi le o ene.
Tsɔ kpe ɖe eŋu la, togbɔ be anya wɔ hã be nàde nuwɔwɔ ƒe dziɖuɖuwo (abe nɔnɔme ƒe akpawo alo kadodowo ene) wò popover me (to nu siawo tsɔtsɔ kpe ɖe allowList
nɔnɔme kple dzesi siwo ŋu woɖe mɔ ɖo ŋu) hã la, nyae be fifia la, popover la mekpɔa keyboard ƒe susu ƒe ɖoɖo dzi o. Ne keyboard zãla ʋu popover la, susu nɔa nusi ʋãa ame ŋu, eye esi wònye be zi geɖe la, popover la mekplɔa nusi ʋãa ame ɖo enumake le nuŋlɔɖia ƒe wɔwɔme me o ta la, kakaɖedzi aɖeke meli be yi ŋgɔ/azi edzi oTABaʋu keyboard zãla aɖe ɖe popover la ŋutɔ me. Kpuie ko la, ne wotsɔ nuwɔwɔ aduadu ƒe dziɖuɖuwo kpe ɖe popover ŋu ko la, anɔ eme be ana dziɖuɖu siawo nazu nusiwo gbɔ womate ŋu aɖo o/womate ŋu azã wo na keyboard zãlawo kple kpekpeɖeŋu mɔ̃ɖaŋunuwo zãlawo o, alo ne mede ɖeke o la, ana woawɔ ɖoɖo si me susu mele o le nusianu me. Le nɔnɔme siawo me la, bu modal dialog zazã boŋ ŋu.
Tiatiawɔblɔɖewo
Woateŋu atsɔ tiatiawɔblɔɖewo ato nyatakaka ƒe nɔnɔmewo alo JavaScript dzi. Le nyatakaka ƒe nɔnɔmewo gome la, tsɔ tiatia ƒe ŋkɔ kpe ɖe data-bs-
, abe alesi wòle le data-bs-animation=""
. Kpɔ egbɔ be yetrɔ tiatia ŋkɔ ƒe case ƒomevi tso camelCase yi kebab-case ne èle tiatiaawo tom to data attributes dzi. Le kpɔɖeŋu me, le esi teƒe be data-bs-customClass="beautifier"
nàzã data-bs-custom-class="beautifier"
.
sanitize
,
sanitizeFn
, kple
tiatiaawo o.allowList
Ŋkɔ | Ƒomevi | Gᴐmedzeƒe | Nuɖᴐɖᴐ |
---|---|---|---|
animation |
boolean ƒe ƒuƒoƒo | true |
Wɔ CSS fade ƒe tɔtrɔ ɖe popover la ŋu |
container |
kaƒoƒo | element | alakpa | false |
Etsɔa popover la kpena ɖe nu aɖe koŋ ŋu. Kpɔɖeŋu: |
content |
kaƒoƒo | element | wᴐ dᴐ | '' |
Default content value ne Ne wotsɔ dɔwɔwɔ aɖe na la, woayɔe kple eƒe |
delay |
xexlẽdzesi | nu | 0 |
Hehe ɖe megbe le popover (ms) ɖeɖefia kple eɣla ɖe megbe - meku ɖe asi trigger ƒomevi ŋu o Ne wotsɔ xexlẽdzesi aɖe na la, wozãa megbedede ɖe ɣla/ɖee fia siaa ŋu Nu ƒe wɔwɔme enye: |
html |
boolean ƒe ƒuƒoƒo | false |
De HTML popover la me. Ne alakpae la, innerText woazã nunɔamesi atsɔ ade emenyawo DOM la me. Zã nuŋɔŋlɔ ne ètsi dzi ɖe XSS ƒe amedzidzedzewo ŋu. |
placement |
kaƒoƒo | wᴐ dᴐ | 'right' |
Ale si woaɖo popover la ɖe ɖoɖo nu - auto | dziƒo | ete | miame | nyui. Ne wozã dɔwɔwɔ aɖe tsɔ nya teƒe si woɖoe ɖo la, woyɔnɛ kple popover DOM node abe eƒe nyaʋiʋli gbãtɔ ene eye triggering element DOM node abe eƒe evelia ene. Woɖo |
selector |
kaƒoƒo | alakpa | false |
Ne wotsɔ tiatiawɔnu aɖe na la, woatsɔ popover nuawo ade asi na taɖodzinu siwo woɖo. Le nuwɔna me la, wozãa esia tsɔ naa HTML me nyatakaka siwo trɔna la nate ŋu atsɔ popovers akpe ɖe eŋu. Kpɔ esia kple kpɔɖeŋu si me nyatakaka geɖe le . |
template |
ka | '<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>' |
Gɔmeɖoanyi HTML be nàzã ne èle popover la wɔm. Woado popover Woado popover
Ele be |
title |
kaƒoƒo | element | wᴐ dᴐ | '' |
Tanya ƒe asixɔxɔ gbãtɔ ne Ne wotsɔ dɔwɔwɔ aɖe na la, woayɔe kple eƒe |
trigger |
ka | 'click' |
Alesi wodzea popover gɔmee - zi | hover | susu tsɔtsɔ ɖo nu ŋu | asi nu. Àte ŋu ato nu geɖe siwo aʋã wò la me; tsɔ dometsotso aɖe ma wo dome. manual womate ŋu atsɔe akpe ɖe nusi aʋã ame bubu aɖeke ŋu o. |
fallbackPlacements |
ƒuƒoƒo ƒe ƒuƒoƒo | ['top', 'right', 'bottom', 'left'] |
Ðe fallback teƒewo gɔme to teƒewo ƒe xexlẽdzesi nana le ƒuƒoƒo me (le ɖoɖo si nu nèdi nu). Ne èdi nyatakaka bubuwo la, kpɔ Popper ƒe nuwɔna ŋuti nuŋlɔɖiwo |
boundary |
kaƒoƒo | na | 'clippingParents' |
Overflow mɔxexeɖenu liƒo na popover (eku ɖe Popper ƒe preventOverflow modifier ko ŋu). Le gɔmedzedzea me la, enye 'clippingParents' eye ateŋu axɔ HTMLElement ƒe nufiame (to JavaScript ɖeɖeko dzi). Ne èdi nyatakaka bubuwo la, kpɔ Popper ƒe detectOverflow docs . |
customClass |
kaƒoƒo | wᴐ dᴐ | '' |
Tsɔ klasswo kpe ɖe popover la ŋu ne woɖee fia. De dzesii be woatsɔ klass siawo akpe ɖe klass ɖesiaɖe si wogblɔ le template la me ŋu. Be nàtsɔ klass geɖe akpe ɖe eŋu la, ma wo dome kple dometsotsowo: Àteŋu atsɔ dɔwɔwɔ aɖe hã si wòle be wòatrɔ ka ɖeka si me klass ŋkɔ bubuwo le la ŋu. |
sanitize |
boolean ƒe ƒuƒoƒo | true |
Na dzadzɛnyenyea nawɔ dɔ alo nàgawɔ dɔ o. If activated 'template' , 'content' kple 'title' tiatiawɔblɔɖewo anye sanitized. Kpɔ akpa si nye sanitizer le míaƒe JavaScript nuŋlɔɖiwo me . |
allowList |
nu | Asixɔxɔ si woɖo ɖi | Nusi me nɔnɔme kple dzesi siwo ŋu woɖe mɔ ɖo le |
sanitizeFn |
null | wᴐ dᴐ | null |
Afisiae nàte ŋu ana wò ŋutɔ wò sanitize dɔwɔwɔ. Esia ate ŋu aɖe vi ne èdi be yeazã agbalẽdzraɖoƒe si woɖo ɖi atsɔ awɔ dzadzɛnyenyedɔ. |
offset |
ƒuƒoƒo | kaƒoƒo | wᴐ dᴐ | [0, 8] |
Offset of the popover ne wotsɔe sɔ kple eƒe taɖodzinu. Àteŋu atsɔ ka aɖe ayi nyatakaka nɔnɔmewo me kple asixɔxɔ siwo woɖe ɖe vovo comma me abe: Ne wozã dɔwɔwɔ aɖe tsɔ nya offset la, woyɔnɛ kple nusi me popper ƒe ɖoɖo, nufiame, kple popper rects le abe eƒe nyaʋiʋli gbãtɔ ene. Wotsɔa nusi ʋãa nu DOM node la toa eme abe nyaʋiʋli evelia ene. Ele be dɔwɔwɔa natrɔ ƒuƒoƒo si me xexlẽdzesi eve le: . Ne èdi nyatakaka bubuwo la, kpɔ Popper ƒe offset docs . |
popperConfig |
null | nu | wᴐ dᴐ | null |
Ne èdi be yeatrɔ Bootstrap ƒe Popper ƒe ɖoɖowɔɖi gbãtɔ la, kpɔ Popper ƒe ɖoɖowɔɖi . Ne wozã dɔwɔwɔ aɖe tsɔ wɔ Popper ƒe ɖoɖowɔɖi la, woyɔnɛ kple nusi me Bootstrap ƒe Popper ƒe ɖoɖowɔɖi gbãtɔ le. Ekpena ɖe ŋuwò nèzãa default la eye nàtsɔe aƒo ƒu kple wò ŋutɔ wò ɖoɖowɔɖi. Ele be dɔwɔwɔa natrɔ ɖoɖowɔɖi ƒe nu aɖe na Popper. |
Data nɔnɔmewo na ame ɖekaɖekawo ƒe popovers
Woateŋu agblɔ tiatia siwo woawɔ na popover ɖekaɖekawo le mɔ bubu nu to nyatakaka ƒe nɔnɔmewo zazã me, abe alesi woɖe eme le etame ene.
Zã dɔwɔwɔ kplepopperConfig
var popover = new bootstrap.Popover(element, {
popperConfig: function (defaultBsPopperConfig) {
// var newPopperConfig = {...}
// use defaultBsPopperConfig if needed...
// return newPopperConfig
}
})
Mɔnuwo
Mɔnu siwo mewɔ ɖeka kple ɣeyiɣi aɖeke o kple tɔtrɔwo
API mɔnuwo katã nye asynchronous eye wodzea tɔtrɔ gɔme . Wotrɔna yia ame si le ka ƒom na la gbɔ ne wonya dze tɔtrɔa gɔme ko gake hafi wòwu enu . Tsɔ kpe ɖe eŋu la, woaŋe aɖaba aƒu mɔnu ƒe yɔyɔ aɖe dzi le akpa si le tɔtrɔm dzi .
ɖe fia
Eɖea element aɖe ƒe popover fiana. Trɔ yi amesi yɔe gbɔ hafi woɖe popover la fia ŋutɔŋutɔ (si nye hafi shown.bs.popover
nudzɔdzɔa nadzɔ). Wobua esia be enye “asi” si wotsɔ ʋãa amedzidzedzea. Womeɖea Popovers siwo ƒe tanya kple emenyawo siaa nye zero-didime fiana gbeɖe o.
myPopover.show()
be
Eɣlaa element aɖe ƒe popover. Trɔ yi amesi yɔe gbɔ hafi woɣla popover la ŋutɔŋutɔ (si nye hafi hidden.bs.popover
nudzɔdzɔa nadzɔ). Wobua esia be enye “asi” si wotsɔ ʋãa amedzidzedzea.
myPopover.hide()
trɔ asi le eŋu
Trɔa element aɖe ƒe popover. Trɔ yi amesi yɔe gbɔ hafi woɖe popover la fia ŋutɔŋutɔ alo ɣlae (si nye hafi shown.bs.popover
alo hidden.bs.popover
nudzɔdzɔa nadzɔ). Wobua esia be enye “asi” si wotsɔ ʋãa amedzidzedzea.
myPopover.toggle()
tsɔe ƒu gbe
Ɣla eye wòtsrɔ̃a element ƒe popover (Eɖea nyatakaka siwo wodzra ɖo ɖe DOM element la dzi ɖa). Popovers siwo zãa delegation (si wowɔ to tiatia ) zazã me laselector
mateŋu atsrɔ̃ ɖekaɖeka le dzidzime ƒe trigger elements dzi o.
myPopover.dispose()
ɖe mᴐ na
Enaa ŋutete si le element aɖe ƒe popover ŋu be woaɖee afia. Wowɔa Popovers ŋudɔ le gɔmedzedzea me.
myPopover.enable()
de dzo le eme
Eɖea ŋutete si le element aɖe ƒe popover fiana la ɖa. Ne wogbugbɔe wɔ dɔ ko hafi woate ŋu aɖe popover la afia.
myPopover.disable()
toggleWowɔ dɔ le eŋu
Toggles ŋutete na element ƒe popover be woaɖe afia alo aɣla.
myPopover.toggleEnabled()
doe ɖe ŋgᴐ
Trɔ asi le element aɖe ƒe popover ƒe nɔƒe ŋu.
myPopover.update()
getInstance ƒe kpɔɖeŋu
Static mɔnu si ɖea mɔ na wò be nàxɔ popover ƒe kpɔɖeŋu si do ƒome kple DOM ƒe akpa aɖe
var exampleTriggerEl = document.getElementById('example')
var popover = bootstrap.Popover.getInstance(exampleTriggerEl) // Returns a Bootstrap popover instance
xɔAloWɔwɔKpɔɖeŋu
Static mɔnu si ɖea mɔ na wò be nàxɔ popover ƒe kpɔɖeŋu si do ƒome kple DOM ƒe akpa aɖe, alo awɔ yeye nenye be womedze egɔme o
var exampleTriggerEl = document.getElementById('example')
var popover = bootstrap.Popover.getOrCreateInstance(exampleTriggerEl) // Returns a Bootstrap popover instance
Nudzɔdzɔwo
Nudzɔdzɔ ƒomevi | Nuɖᴐɖᴐ |
---|---|
ɖee fia.bs.popover | Nudzɔdzɔ sia doa dzo enumake ne woyɔ show kpɔɖeŋu mɔnu la. |
woɖee fia.bs.popover | Woɖea nudzɔdzɔ sia ɖa ne wowɔ popover la be wòadze na zãla (alala CSS ƒe tɔtrɔwo be woawu enu). |
ɣla.bs.ahedada | Woɖea nudzɔdzɔ sia ɖa enumake ne woyɔ hide instance mɔnu la. |
ɣaɣla.bs.ahedada | Woɖea nudzɔdzɔ sia ɖa ne popover la ɣla ɖe zãla la vɔ (alala be CSS ƒe tɔtrɔwo nawu enu). |
wotsɔ de eme.bs.popover | Woɖea nudzɔdzɔ sia ɖa le nudzɔdzɔa megbe show.bs.popover ne wotsɔ popover ƒe nɔnɔmetata kpe ɖe DOM ŋu. |
var myPopoverTrigger = document.getElementById('myPopover')
myPopoverTrigger.addEventListener('hidden.bs.popover', function () {
// do something...
})