Source

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.js ŋ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.jssi me Popper.js 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 beutil.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.
  • .disabledEle be woaʋu dɔwɔnu ƒe aɖaŋuɖoɖowo na alo elementwo ɖe disabledwrapper 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.

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-togglenɔ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:

Tight pants next level keffiyeh ɖewohĩ mèse wo ŋkɔ kpɔ o. Fotoɖeƒe ɖaɖa raw denim letterpress vegan dɔla kotoku stumptown. Agble-to-kplɔ̃ seitan, mcsweeney ƒe fixie si li tegbee quinoa 8-bit american awuwo le terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo dziɖegbe ƒe avuwo. Tofu biodiesel williamsburg marfa, ene loko mcsweeney ƒe kɔ vegan chambray. A really ironic artisan whatever keytar , scenester agble-ɖe-kplɔ̃ banksy Austin twitter asi freegan cred raw denim ɖeka-dzɔtsoƒe kɔfi viral.

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 autokplescroll

Dɔwɔnu ƒe dzesi ƒe nɔƒe dzea agbagba be yeatrɔ le eɖokui si ne dzila ƒe nugoe aɖe le overflow: autoalo overflow: scrollabe míaƒe .table-responsive, gake egaléa teƒe gbãtɔ ƒe nɔƒe ɖe te kokoko. Be nàkpɔ egbɔ la, ɖo boundarytiatia 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 datanɔnɔme aɖe ko eye titlele 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 topto 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ɔ 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. Tsɔ kpe ɖe eŋu la, kpekpeɖeŋunamɔnu akpa gãtɔ meɖea gbeƒã dɔwɔnu ƒe aɖaŋuɖoɖoa fifia le nɔnɔme sia me o.

Tsɔ kpe ɖe eŋu la, mègaɖo ŋu ɖe eŋu ɖeɖeko hoverbe 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 disablednɔ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-eventson 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="".

Ŋ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: container: 'body'. Tiatia sia ɖea vi ŋutɔ le esi wòɖea mɔ na wò be nàɖo dɔwɔnu ƒe nugbɔ ɖe nuŋlɔɖi ƒe sisi me le nusi te ɖe nusi ʋãa nu ŋu - si axe mɔ na dɔwɔnu ƒe nugbɔ be wòagadzo le nusi ʋãa dɔa gbɔ le fesre ƒe lolome tɔtrɔ me o.

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:delay: { "show": 500, "hide": 100 }

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 titlela gɔme le dɔwɔnu ƒe aɖaŋuɖoɖoa me. Ne alakpae la, woazã jQuery ƒe textmɔ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ᴐ 'dzi'

Alesi woaɖo dɔwɔnu ƒe aɖaŋuɖoɖoa ɖe teƒe - auto | dziƒo | ete | miame | nyui.
Ne autowogblɔe la, atrɔ asi le dɔwɔnu ƒe aɖaŋuɖoɖoa ŋu le mɔ si trɔna nu.

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 thisnya siwo ƒo xlãe la ɖe dɔwɔnu ƒe aɖaŋuɖoɖo ƒe kpɔɖeŋua dzi.

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ɔ 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="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 titleɖe .tooltip-inner.

.arrowava zu dɔwɔnua ƒe aŋutrɔ.

Ele be .tooltipklass kple role="tooltip".

tanya kaƒoƒo | element | wᴐ dᴐ '' .

Tanya ƒe asixɔxɔ gbãtɔ ne titlenɔnɔme mele afima o.

Ne wotsɔ dɔwɔwɔ aɖe na la, woayɔe kple eƒe thisnufiameɖoɖo ɖe element si ŋu wotsɔ dɔwɔnu ƒe aɖaŋuɖoɖoa kpe ɖo la ŋu.

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.

'manual'ɖee fia be woadze dɔwɔnu ƒe aɖaŋuɖoɖoa gɔme le ɖoɖo nu to .tooltip('show'), .tooltip('hide')kple .tooltip('toggle')mɔnuwo dzi; womate ŋu atsɔ asixɔxɔ sia aƒo ƒu kple nusi aʋã ame bubu aɖeke o.

'hover'le eɖokui si ana dɔwɔnu ƒe aɖaŋuɖoɖo siwo womate ŋu adze egɔme to keyboard la dzi o, eye ne mɔnu bubu siwo dzi woato agblɔ nyatakaka mawo ke na keyboard zãlawo li ko hafi woazã wo.

offset ƒe ƒuƒoƒo xexlẽdzesi | ka 0. Dɔwɔnu ƒe aɖaŋuɖoɖo ƒe vovototodedeameme ne wotsɔe sɔ kple eƒe taɖodzinu. Ne èdi nyatakaka bubuwo la, kpɔ Popper.js ƒ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.js ƒe nuwɔna ŋuti nuŋlɔɖiwo
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.js ƒe preventOverflow docs .

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 .

Kpɔ míaƒe JavaScript nuŋlɔɖiwo hena nyatakaka bubuwo.

$().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.tooltipnudzɔ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.tooltipnudzɔ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.tooltipalo hidden.bs.tooltipnudzɔ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ɔ showkpɔɖ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ɔ hideinstance 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.tooltipne 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…
})