Dɔwɔnu ƒe Aɖaŋuɖoɖowo
Nuŋlɔɖiwo kple kpɔɖeŋuwo hena Bootstrap dɔwɔnu ƒe aɖaŋuɖoɖo tɔxɛwo tsɔtsɔ kpe ɖe eŋu kple CSS kple JavaScript to CSS3 zazã me na nɔnɔmetatawo kple nyatakaka-nɔnɔmewo na teƒea ƒe tanya dzraɖoƒe.
Kpɔɖeŋunyagbɔgblɔ
Nusiwo wòle be nànya ne èle dɔwɔnu ƒe aɖaŋuɖoɖo ƒe kpeɖeŋutɔ zãm:
- Dɔwɔnu ƒe aɖaŋuɖoɖowo ɖoa ŋu ɖe 3rd party agbalẽdzraɖoƒe Popper ŋu hena teƒ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 dɔwɔnu ƒe aɖaŋuɖoɖowo nawɔ dɔ! - Ne èle míaƒe JavaScript tum tso dzɔtsoƒe la, ebia be
util.js
. - Dɔwɔnu ƒe aɖaŋuɖoɖowo nye tiatiawɔwɔ le dɔwɔwɔ ta, eyata ele be wò ŋutɔ nàdze wo gɔme .
- Womeɖea dɔwɔnu ƒe aɖaŋuɖoɖo siwo ƒe tanyawo ƒe didime nye zero la fiana 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). - Dɔwɔnu ƒe aɖaŋuɖoɖowo ʋuʋu ɖe nu ɣaɣlawo dzi mawɔ dɔ o.
.disabled
Ele be woaʋu dɔwɔnu ƒe aɖaŋuɖoɖowo na alo elementwo ɖedisabled
wrapper element dzi.- Ne wodze egɔme tso kadodo siwo le fli geɖe dzi me la, dɔwɔnu ƒe aɖaŋuɖoɖowo anɔ titina. Zã
white-space: nowrap;
le wò<a>
s dzi be nàƒo asa na nuwɔna sia. - Ele be woaɣla dɔwɔnu ƒe aɖaŋuɖoɖowo hafi woaɖe woƒe akpa siwo sɔ la ɖa le DOM la me.
- Woateŋu adze dɔwɔnu ƒe aɖaŋuɖoɖowo gɔme akpe ɖe nusi 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ɔ .
Nu mawo katã le asiwòa? Gã, na míakpɔ alesi wowɔa dɔe kple kpɔɖeŋu aɖewo ɖa.
Kpɔɖeŋu: Na dɔwɔnu ƒe aɖaŋuɖoɖowo nawɔ dɔ le afisiafi
Mɔ ɖeka si dzi nàto adze dɔwɔnu ƒe aɖaŋuɖoɖowo katã gɔme le axa aɖe dzi enye be nàtia wo ɖe woƒe data-toggle
nɔnɔme nu:
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
Kpɔɖeŋuwo
Tsɔ asi ɖo kadodo siwo le ete la dzi be nàkpɔ dɔwɔnu ƒe aɖaŋuɖoɖowo:
Teƒeɖoɖo ƒe nuŋɔŋlɔ be woatsɔ aɖe kadodo aɖewo siwo le fli me kple dɔwɔnu ƒe aɖaŋuɖoɖowo afia. Esia nye filler ko fifia, amewula aɖeke meli o. Emenya siwo woda ɖe afisia be woasrɔ̃ nuŋɔŋlɔ ŋutɔŋutɔ ƒe anyinɔnɔ ko . Eye esiawo katã be wòana nàkpɔ alesi dɔwɔnu ƒe aɖaŋuɖoɖowo anɔ ne wozã wo le nɔnɔme ŋutɔŋutɔwo me la ƒe susu aɖe ko. Eyata míele mɔ kpɔm be èkpɔ alesi dɔwɔnu siawo siwo le kadodowo dzi ate ŋu awɔ dɔ le nuwɔna me azɔ, ne ènya zã wo le wò ŋutɔ wò nyatakakadzraɖoƒe alo dɔ aɖe ko.
Tsɔ asi ɖo abɔta siwo le ete la dzi be nàkpɔ dɔwɔnu ƒe aɖaŋuɖoɖo eneawo ƒe mɔfiamewo: etame, ɖusime, ete, kple miame.
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="top" title="Tooltip on top">
Tooltip on top
</button>
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="right" title="Tooltip on right">
Tooltip on right
</button>
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom">
Tooltip on bottom
</button>
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="left" title="Tooltip on left">
Tooltip on left
</button>
Eye esi wotsɔ HTML si wowɔ ɖe ɖoɖo nu kpe ɖe eŋu la:
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-html="true" title="<em>Tooltip</em> <u>with</u> <b>HTML</b>">
Tooltip with HTML
</button>
Zãzã
Dɔwɔnu ƒe aɖaŋuɖoɖo ƒe kpeɖeŋutɔa wɔa nyatakakawo kple dzesidede ne wobiae, eye le gɔmedzedzea me la, etsɔa dɔwɔnu ƒe aɖaŋuɖoɖowo ɖoa woƒe nusi ʋãa ame la megbe.
Dze dɔwɔnu ƒe aɖaŋuɖoɖoa gɔme to JavaScript dzi:
$('#example').tooltip(options)
Overflow auto
kplescroll
Dɔwɔnu ƒe dzesi ƒe nɔƒe dzea agbagba be yeatrɔ le eɖokui si ne dzila ƒe nugoe aɖe le overflow: auto
alo overflow: scroll
abe míaƒe .table-responsive
, gake egaléa teƒe gbãtɔ ƒe nɔƒe ɖe te kokoko. Be nàkpɔ egbɔ la, ɖo boundary
tiatia la ɖe nusianu si menye asixɔxɔ gbãtɔ o, 'scrollParent'
, abe 'window'
:
$('#example').tooltip({ boundary: 'window' })
Dzesidede dzesiwo
Dzesi si hiã na dɔwɔnu ƒe aɖaŋuɖoɖo nye data
nɔnɔme aɖe ko eye title
le HTML ƒe akpaa dzi la, èdi be dɔwɔnu ƒe aɖaŋuɖoɖo nanɔ ye si. Dɔwɔnu ƒe dzesi ƒe dzesi si wowɔ la le bɔbɔe vie, togbɔ be ebia teƒe aɖe hã (le gɔmedzedzea me la, woɖoe ɖe top
to plugin la dzi).
Dɔwɔnu ƒe aɖaŋuɖoɖowo wɔwɔ be woawɔ dɔ na keyboard kple kpekpeɖeŋu mɔ̃ɖaŋununya zãlawo
Ele be nàtsɔ dɔwɔnu ƒe aɖaŋuɖoɖowo akpe ɖe HTML ƒe akpa siwo te ŋu nɔa te ɖe keyboard dzi eye wowɔa nu aduadu tso blema ke (abe kadodowo alo nuŋlɔɖiwo dzi kpɔkpɔ ene) ko ŋu. Togbɔ be woateŋu ana HTML ƒe akpa siwo wowɔna le wo ɖokui si (abe <span>
s ene) nanye esiwo ŋu woate ŋu aɖo ŋkui 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ŋunamɔnu akpa gãtɔ meɖea gbeƒã dɔwɔnu ƒe aɖaŋuɖoɖoa 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ò dɔwɔnu ƒe aɖaŋuɖoɖo o, elabena esia ana wò dɔwɔnu ƒe aɖaŋuɖoɖowo mate ŋu aʋã keyboard zãlawo o.
<!-- HTML to write -->
<a href="#" data-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="arrow"></div>
<div class="tooltip-inner">
Some tooltip text!
</div>
</div>
Nuwɔametɔwo ƒe akpawo
Elements siwo si disabled
nɔnɔmea le la mewɔa dɔ ɖekae o, si fia be ezãlawo mateŋu atsɔ susu aɖo wo ŋu, atsɔ asi aɖo wo dzi, alo azi wo dzi atsɔ adze dɔwɔnu ƒe aɖaŋuɖoɖo (alo popover) gɔme o. Abe dɔwɔwɔ ene la, àdi be yeaʋu dɔwɔnu ƒe aɖaŋuɖoɖoa tso agbalẽ xatsaxatsa <div>
alo <span>
, si wowɔ nyuie be woate ŋu atsɔ keyboard-focusable zã tabindex="0"
, eye yeaɖe asi le pointer-events
on the disabled element la ŋu.
<span class="d-inline-block" tabindex="0" data-toggle="tooltip" title="Disabled tooltip">
<button class="btn btn-primary" style="pointer-events: none;" type="button" disabled>Disabled button</button>
</span>
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 dɔwɔnu ƒe aɖaŋuɖoɖoa dzi |
nugoe me nugoe | kaƒoƒo | element | alakpa | alakpa | Tsɔ dɔwɔnu ƒe aɖaŋuɖoɖoa kpe ɖe nu aɖe koŋ ŋu. Kpɔɖeŋu: |
hehe ɖe megbe | xexlẽdzesi | nu | 0. | Hehe ɖe megbe le dɔwɔnu ƒe aɖaŋuɖoɖo ɖeɖefia kple eɣla ɖe megbe (ms) - meku ɖe asi ƒe ʋuʋu ƒ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 | Ðe mɔ na HTML le dɔwɔnu ƒe aɖaŋuɖoɖoa me. Ne enye nyateƒe la, woaɖe HTML dzesi siwo le dɔwɔnu ƒe aɖaŋuɖoɖoa me Zã nuŋɔŋlɔ ne ètsi dzi ɖe XSS ƒe amedzidzedzewo ŋu. |
ɖoɖo ɖe teƒe aɖe | kaƒoƒo | wᴐ dᴐ | 'dzi' | Alesi woaɖo dɔwɔnu ƒe aɖaŋuɖoɖoa ɖe teƒe - 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 dɔwɔnu ƒe dzesi DOM node abe eƒe nyaʋiʋli gbãtɔ ene eye nusi ʋãa nu 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ɔ dɔwɔnu ƒe aɖaŋuɖoɖo nuawo ade asi na taɖodzinu siwo woɖo. Le nuwɔna me la, wozãa esia tsɔ wɔa dɔwɔnu ƒe aɖaŋuɖoɖowo hã ŋudɔ ɖe DOM ƒe akpa siwo wotsɔ kpe ɖe eŋu le mɔ si trɔna nu ( jQuery.on kpekpeɖeŋu). Kpɔ esia kple kpɔɖeŋu si me nyatakaka geɖe le . |
ƒe nɔnɔmetata | ka | '<div class="tooltip" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>' |
Gɔmeɖoanyi HTML si nàzã ne èle dɔwɔnu ƒe aɖaŋuɖoɖoa wɔm. Woado dɔwɔnu ƒe aɖaŋuɖoɖoa
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 | 'hover focus'. | Alesi woadze dɔwɔnu ƒe aɖaŋuɖoɖo 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.
|
offset ƒe ƒuƒoƒo | xexlẽdzesi | kaƒoƒo | wᴐ dᴐ | 0. | Dɔwɔnu ƒe aɖaŋuɖoɖo ƒe vovototodedeameme ne wotsɔe sɔ kple eƒe taɖodzinu. Ne wozã dɔwɔwɔ aɖe tsɔ nya offset la, woyɔnɛ kple nusi me offset data le abe eƒe nyaʋiʋli gbãtɔ ene. Ele be dɔwɔwɔa natrɔ nusi ƒe wɔwɔme le ɖeka. Wotsɔa nusi ʋãa nu DOM node la toa eme abe nyaʋiʋli evelia ene. 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 dɔwɔnu ƒe aɖaŋuɖoɖoa ŋ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 dɔwɔnu ƒe aɖaŋuɖoɖo. 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. Ne wowɔ dɔ 'template' eye 'title' woawɔ tiatiawɔblɔɖewo ŋudɔ. 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 |
Nyatakaka ƒe nɔnɔmewo na dɔwɔnu ɖekaɖekawo ƒe aɖaŋuɖoɖowo
Woateŋu agblɔ tiatia siwo woawɔ na dɔwɔnu ɖekaɖekawo le mɔ bubu nu to nyatakakawo ƒe nɔnɔmewo zazã me, abe alesi míeɖ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 .
$().tooltip(options)
Kpe dɔwɔnu ƒe aɖaŋuɖoɖo ƒe asiléƒe ɖe element ƒe nuƒoƒoƒu ŋu.
.tooltip('show')
Eɖea element aɖe ƒe dɔwɔnu ƒe aɖaŋuɖoɖo fiana. Trɔ yi yɔla gbɔ hafi woɖe dɔwɔnu ƒe aɖaŋuɖoɖoa fia ŋutɔŋutɔ (si nye hafi shown.bs.tooltip
nudzɔdzɔa nadzɔ). Wobua esia be enye dɔwɔnu ƒe aɖaŋuɖoɖoa ƒe “asi” ƒe dɔwɔwɔ. Womeɖea dɔwɔnu ƒe aɖaŋuɖoɖo siwo ƒe tanyawo ƒe didime nye zero la fiana gbeɖe o.
$('#element').tooltip('show')
.tooltip('hide')
Ɣla element aɖe ƒe dɔwɔnu ƒe aɖaŋuɖoɖo. Trɔ yi yɔla gbɔ hafi woɣla dɔwɔnu ƒe aɖaŋuɖoɖoa ŋutɔŋutɔ (si nye hafi hidden.bs.tooltip
nudzɔdzɔa nadzɔ). Wobua esia be enye dɔwɔnu ƒe aɖaŋuɖoɖoa ƒe “asi” ƒe dɔwɔwɔ.
$('#element').tooltip('hide')
.tooltip('toggle')
Trɔa element aɖe ƒe dɔwɔnu ƒe aɖaŋuɖoɖo. Trɔ yi yɔla gbɔ hafi woɖe dɔwɔnu ƒe aɖaŋuɖoɖoa fia ŋutɔŋutɔ alo ɣlae (si nye hafi shown.bs.tooltip
alo hidden.bs.tooltip
nudzɔdzɔa nadzɔ). Wobua esia be enye dɔwɔnu ƒe aɖaŋuɖoɖoa ƒe “asi” ƒe dɔwɔwɔ.
$('#element').tooltip('toggle')
.tooltip('dispose')
Eɣlaa element aɖe ƒe dɔwɔnu ƒe aɖaŋuɖoɖo eye wòtsrɔ̃nɛ. Dɔwɔnu ƒe aɖaŋuɖoɖo siwo zãa delegation (si wowɔ to tiatia ) zazã me laselector
mateŋu atsrɔ̃ ɖekaɖeka le dzidzime ƒe trigger elements dzi o.
$('#element').tooltip('dispose')
.tooltip('enable')
Enaa ŋutete be woaɖee afia element aɖe ƒe dɔwɔnu ƒe aɖaŋuɖoɖo. Wowɔa dɔwɔnu ƒe aɖaŋuɖoɖowo ŋudɔ le gɔmedzedzea me.
$('#element').tooltip('enable')
.tooltip('disable')
Ðe ŋutete si le element ƒe dɔwɔnu ƒe aɖaŋuɖoɖo ŋu be woaɖee afia la ɖa. Ne wogbugbɔe wɔ dɔ ko hafi woate ŋu aɖe dɔwɔnu ƒe aɖaŋuɖoɖoa afia.
$('#element').tooltip('disable')
.tooltip('toggleEnabled')
Trɔ ŋutete si le element ƒe dɔwɔnu ƒe aɖaŋuɖoɖo ŋu be woaɖee afia alo aɣla.
$('#element').tooltip('toggleEnabled')
.tooltip('update')
Trɔ asi le element aɖe ƒe dɔwɔnu ƒe aɖaŋuɖoɖo ƒe nɔƒe ŋu.
$('#element').tooltip('update')
Nudzɔdzɔwo
Nudzɔdzɔ Ƒomevi | Nuɖᴐɖᴐ |
---|---|
show.bs.dɔwɔnu ƒe aɖaŋuɖoɖo | Nudzɔdzɔ sia doa dzo enumake ne woyɔ show kpɔɖeŋu mɔnu la. |
woɖee fia.bs.dɔwɔnu ƒe aɖaŋuɖoɖo | Woɖea nudzɔdzɔ sia ɖa ne wowɔ dɔwɔnu ƒe aɖaŋuɖoɖoa be wòadze na zãla (alala be CSS ƒe tɔtrɔwo nawu enu). |
hide.bs.dɔwɔnu ƒe aɖaŋuɖoɖo | Woɖea nudzɔdzɔ sia ɖa enumake ne woyɔ hide instance mɔnu la. |
hidden.bs.dɔwɔnu ƒe aɖaŋuɖoɖo | Woɖea nudzɔdzɔ sia ɖa ne dɔwɔnu ƒe aɖaŋuɖoɖoa ɣla ɖe zãla la vɔ (alala be CSS ƒe tɔtrɔwo nawu enu). |
inserted.bs.dɔwɔnu ƒe aɖaŋuɖoɖo | Woɖea nudzɔdzɔ sia ɖa le nudzɔdzɔa megbe show.bs.tooltip ne wotsɔ dɔwɔnu ƒe aɖaŋuɖoɖo ƒe nɔnɔmetata kpe ɖe DOM ŋu. |
$('#myTooltip').on('hidden.bs.tooltip', function () {
// do something...
})