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.
- Ne èle míaƒe JavaScript tum tso dzɔtsoƒe la, ebia be
util.js
. - 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-toggle
nɔnɔme nu:
$(function () {
$('[data-toggle="popover"]').popover()
})
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ŋ.
$(function () {
$('.example-popover').popover({
container: 'body'
})
})
Kpɔɖeŋu
<button type="button" class="btn btn-lg btn-danger" data-toggle="popover" title="Popover title" data-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.
<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="top" data-content="Top popover">
Popover on top
</button>
<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="right" data-content="Right popover">
Popover on right
</button>
<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="bottom" data-content="Bottom popover">
Popover on bottom
</button>
<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="left" data-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-toggle="popover" data-trigger="focus" title="Dismissible popover" data-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</a>
$('.popover-dismiss').popover({
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 dɔwɔwɔ ene la, àdi be yeaʋu popover la tso wrapper me <div>
alo <span>
eye yeaɖe asi le pointer-events
on the disabled element la ŋu.
Le popover triggers siwo nye nuwɔametɔwo gome la, àte ŋu alɔ̃ hã data-trigger="hover"
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" data-toggle="popover" data-content="Disabled popover">
<button class="btn btn-primary" style="pointer-events: none;" type="button" disabled>Disabled button</button>
</span>
Zãzã
Na popovers nawɔ dɔ to JavaScript dzi:
$('#example').popover(options)
GPU ƒe duƒuƒu
Popovers dzena ɣeaɖewoɣi blurry le Windows 10 dɔwɔnuwo dzi le GPU ƒe ablaɖeɖe kple ɖoɖoa ƒe DPI si woɖɔli ta. Dɔwɔwɔ na esia le v4 me enye be nàwɔ GPU ƒe ablaɖeɖe nuwɔametɔe abe alesi wòhiã ene le wò popovers dzi.
Woɖo aɖaŋu be woaɖɔe ɖo:
Popper.Defaults.modifiers.computeStyle.gpuAcceleration = !(window.devicePixelRatio < 1.5 && /Win/.test(navigator.platform))
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ɔ be nàde nuwɔwɔ ƒe dziɖuɖuwo hã (abe nɔnɔme ƒe akpawo alo kadodowo ene) wò popover me (to nu siawo tsɔtsɔ kpe ɖe whiteList
nɔnɔme kple dzesi siwo ŋu woɖe mɔ ɖo alo esiwo ŋu woɖe mɔ ɖo ŋu me) 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-
, abe alesi wòle le data-animation=""
.
sanitize
,
sanitizeFn
kple
tiatiaawo o.whiteList
Ŋkɔ | Ƒomevi | Gᴐmedzeƒe | Nuɖᴐɖᴐ |
---|---|---|---|
nɔnɔmetata si me woɖea nɔnɔmetatawo le | boolean ƒe ƒuƒoƒo | nyateƒe | Wɔ CSS fade ƒe tɔtrɔ ɖe popover la ŋu |
nugoe me nugoe | kaƒoƒo | element | alakpa | alakpa | Etsɔa popover la kpena ɖe nu aɖe koŋ ŋu. Kpɔɖeŋu: |
eme nuwo | kaƒoƒo | element | wᴐ dᴐ | '' . | Default content value ne Ne wotsɔ dɔwɔwɔ aɖe na la, woayɔe kple eƒe |
hehe ɖe megbe | 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 | alakpa | De HTML popover la me. Ne alakpae la, woazã jQuery ƒe text mɔnu atsɔ ade emenyawo DOM la me. Zã nuŋɔŋlɔ ne ètsi dzi ɖe XSS ƒe amedzidzedzewo ŋu. |
ɖoɖo ɖe teƒe aɖe | kaƒoƒo | wᴐ dᴐ | 'nyui' | 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 |
tiatiawɔla | kaƒoƒo | alakpa | alakpa | 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 . |
ƒe nɔnɔmetata | ka | '<div class="popover" role="tooltip"><div class="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 |
tanya | 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 |
daƒe | ka | 'zi edzi'. | 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. |
offset ƒe ƒuƒoƒo | xexlẽdzesi | ka | 0. | Offset of the popover ne wotsɔe sɔ kple eƒe taɖodzinu. Ne èdi nyatakaka bubuwo la, kpɔ Popper ƒe offset docs . |
fallbackNuɖoɖo ɖe teƒe aɖe | kaƒoƒo | ƒuƒoƒo ƒe ƒuƒoƒo | 'ti kpo' | Ðe mɔ be woagblɔ ɖoƒe si Popper azã le fallback me. Ne èdi nyatakaka bubuwo la, kpɔ Popper ƒe nuwɔna ŋuti nuŋlɔɖiwo |
customClass ƒe ɖoɖo | 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. |
liƒo dzi | kaƒoƒo | na | 'agbalẽ xatsaxatsa dzila'. | Overflow mɔxenu liƒo na popover. Xɔ 'viewport' , 'window' , 'scrollParent' , alo HTMLElement ƒe nufiame ƒe asixɔxɔwo (JavaScript ɖeɖeko). Ne èdi nyatakaka bubuwo la, kpɔ Popper ƒe preventOverflow docs . |
tsɔ kɔ na ame | boolean ƒe ƒuƒoƒo | nyateƒe | 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 . |
whiteList ƒe xexlẽdzesi | nu | Asixɔxɔ si woɖo ɖi | Nusi me nɔnɔme kple dzesi siwo ŋu woɖe mɔ ɖo le |
dzadzɛnyenyeFn | null | wᴐ dᴐ | ƒuƒlu | 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ɔ. |
popper ƒe Ðoɖowɔɖi | null | nu | ƒuƒlu | Ne èdi be yeatrɔ Bootstrap ƒe Popper ƒe ɖoɖowɔɖi gbãtɔ la, kpɔ Popper ƒe ɖoɖowɔɖi |
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.
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 .
$().popover(options)
Edzea popovers gɔme na element nuƒoƒoƒu.
.popover('show')
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.
$('#element').popover('show')
.popover('hide')
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.
$('#element').popover('hide')
.popover('toggle')
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.
$('#element').popover('toggle')
.popover('dispose')
Eɣlaa element aɖe ƒe popover eye wòtsrɔ̃nɛ. Popovers siwo zãa delegation (si wowɔ to tiatia ) zazã me laselector
mateŋu atsrɔ̃ ɖekaɖeka le dzidzime ƒe trigger elements dzi o.
$('#element').popover('dispose')
.popover('enable')
Enaa ŋutete si le element aɖe ƒe popover ŋu be woaɖee afia. Wowɔa Popovers ŋudɔ le gɔmedzedzea me.
$('#element').popover('enable')
.popover('disable')
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.
$('#element').popover('disable')
.popover('toggleEnabled')
Toggles ŋutete na element ƒe popover be woaɖe afia alo aɣla.
$('#element').popover('toggleEnabled')
.popover('update')
Trɔ asi le element aɖe ƒe popover ƒe nɔƒe ŋu.
$('#element').popover('update')
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. |
$('#myPopover').on('hidden.bs.popover', function () {
// do something...
})