Source

Popovers

Faʻamaumauga ma faʻataʻitaʻiga mo le faʻaopoopoina o Bootstrap popovers, pei o loʻo maua i iOS, i soʻo se elemene i luga o lau 'upega tafaʻilagi.

Vaaiga lautele

Mea e iloa pe a faʻaaogaina le popover plugin:

  • Popovers fa'alagolago ile faletusi lona tolu Popper.js 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.jso loʻo i ai Popper.js ina ia mafai ona galue popovers!
  • Popovers manaʻomia le meafaigaluega faʻapipiʻi e fai ma faʻalagolago.
  • Afai o loʻo e fausiaina la matou JavaScript mai le puna, e manaʻomiautil.js .
  • Popovers e filifili i totonu mo mafuaʻaga o faʻatinoga, o lea e tatau ai ona e amataina oe lava ia .
  • Ole umi ole umi titlema contenttau o le a le fa'aalia se popover.
  • 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).
  • O le faʻaosoina o popovers i elemene natia o le a le aoga.
  • Popovers mo .disabledpo'o disabledelemene e tatau ona fa'aoso i luga o se elemene afifi.
  • A fa'aoso mai taula e afifi i luga o le tele o laina, popovers o le a totonugalemu i le va o taula' lautele lautele. Fa'aoga white-space: nowrap;i lou <a>s e aloese ai mai lenei amio.
  • Popovers e tatau ona natia aʻo leʻi aveesea a latou elemene tutusa mai le DOM.

Fa'aauau le faitau e va'ai pe fa'afefea ona galue popovers ma nisi fa'ata'ita'iga.

Fa'ata'ita'iga: Fa'aaga popovers i so'o se mea

O se tasi o auala e amata ai popovers uma i luga o se itulau o le filifilia lea e ala i o latou data-toggleuiga:

$(function () {
  $('[data-toggle="popover"]').popover()
})

Faataitaiga: Faʻaaogaina le containerfilifiliga

A iai ni au sitaili i luga o se elemene matua e faʻalavelave i se popover, e te manaʻo e faʻamaonia se aganuʻu containerina ia faʻaalia le HTML o le popover i totonu o lena elemene nai lo.

$(function () {
  $('.example-popover').popover({
    container: 'body'
  })
})

Faataitaiga

<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>

Fa ituala

E fa filifiliga o lo'o avanoa: luga, taumatau, pito i lalo, ma agavale fa'aoga.

<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="top" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
  Popover on top
</button>

<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="right" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
  Popover on right
</button>

<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="bottom" data-content="Vivamus
sagittis lacus vel augue laoreet rutrum faucibus.">
  Popover on bottom
</button>

<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="left" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
  Popover on left
</button>

Fa'ate'a ile isi kiliki

Fa'aaoga le focusfa'aoso e fa'ate'a ai popovers i le isi kiliki a le tagata fa'aoga o se elemene ese nai lo le elemene sosolo.

Fa'ailoga fa'apitoa e mana'omia mo le fa'ate'aina-i le isi-kiliki

Mo le fetaui lelei o le su'esu'ega ma le fa'aogaina o amioga, e tatau ona e fa'aogaina le <a>pine, ae le o le <button>pine, ma e tatau fo'i ona e aofia ai se tabindexuiga.

<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'
})

Elemene le atoatoa

O elemene e iai le disableduiga e le fegalegaleai, o lona uiga e le mafai e tagata faʻaoga ona faʻafefe pe kiliki i latou e faʻaoso ai se popover (poʻo se meafaigaluega). I le avea ai o se fofo, e te manaʻo e faʻaoso le popover mai se afifi <div>poʻo <span>ma faʻamalo le pointer-eventsi luga o le elemene le atoatoa.

Mo fa'aoso popover fa'aletonu, atonu e te mana'o data-trigger="hover"fo'i ina ia fa'aalia le popover o se fa'aaliga va'aia vave i au tagata fa'aoga ona latou te le o fa'amoemoe e kiliki i luga o se elemene fa'aletonu.

<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>

Fa'aoga

Fa'amalo popovers e ala i le JavaScript:

$('#example').popover(options)

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-, pei o le data-animation="".

Igoa Ituaiga Fa'atonu Fa'amatalaga
animation boolean moni Fa'aoga se suiga e mou atu CSS i le popover
pusa manoa | elemene | pepelo pepelo

Fa'aopoopo le popover i se elemene patino. Faataitaiga: container: 'body'. O lenei filifiliga e sili ona aoga ona e mafai ai e oe ona faʻatulagaina le popover i le tafe o le pepa i tafatafa o le elemene faʻaoso - lea e taofia ai le popover mai le opeopea ese mai le elemene faʻaosoina i le taimi o le suiga o le faamalama.

anotusi manoa | elemene | galuega faatino ''

Fa'aleaogaina mea taua pe afai data-contente le o iai le uiga.

Afai e tu'uina atu se galuega, o le a vala'au ma lona thisfa'asinomaga seti i le elemene o lo'o fa'apipi'i i ai le popover.

tuai numera | mea faitino 0

Fa'atuai ona fa'aali ma nana le popover (ms) - e le fa'atatau i le fa'ailoga tusi 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:delay: { "show": 500, "hide": 100 }

html boolean pepelo Fa'aofi le HTML i totonu o le popover. Afai e sese, o le a faʻaaogaina le textauala a le jQuery e faʻaofi ai mea i totonu ole DOM. Fa'aoga tusitusiga pe a e popole i osofa'iga a le XSS.
tu'uga manoa | galuega faatino 'tauagavale'

Fa'afefea ona fa'atulaga le popover - auto | pito i luga | lalo | agavale | tauagavale.
Pe autoa faʻamaonia, o le a toe faʻaleleia le popover.

Pe a faʻaaogaina se galuega e fuafua ai le tuʻuina, e taʻua i le popover DOM node e fai ma ana finauga muamua ma le elemene DOM node lona lua. Ua thisseti le tala i le fa'ata'ita'iga popover.

tagata filifilia manoa | pepelo pepelo Afai e tu'uina atu se tagata filifilia, o mea fa'apipi'i o le a tu'uina atu i fa'amoemoe fa'apitoa. I le fa'ata'ita'iga, o lo'o fa'aaogaina e mafai ai ona fa'aopoopoina mea fa'apitoa HTML e fa'aopoopo ai popovers. Vaʻai i lenei mea ma se faʻataʻitaʻiga faʻamatalaga .
mamanu manoa '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>'

Fa'avae HTML e fa'aoga pe a fai le popover.

O le popover's titleo le a tui i totonu o le .popover-header.

O le popover's contento le a tui i totonu o le .popover-body.

.arrowo le a avea ma aū o le popover.

O le elemene afifi pito i fafo e tatau ona i ai le .popovervasega.

suafa manoa | elemene | galuega faatino ''

Fa'aigoa fa'aigoa tau pe afai titlee le o iai le uiga.

Afai e tu'uina atu se galuega, o le a vala'au ma lona thisfa'asinomaga seti i le elemene o lo'o fa'apipi'i i ai le popover.

fa'aoso manoa 'kiliki' E fa'afefea ona fa'aoso popover - kiliki | lele | taula'i | tusi lesona. E mafai ona e pasia le tele o fa'aoso; tuueseese ma se avanoa. 'manual' e le mafai ona tu'ufa'atasia ma so'o se isi fa'aoso.
fa'apena numera | manoa 0 Offset o le popover e faatatau i lona sini. Mo nisi fa'amatalaga va'ai ile Popper.js's offset docs .
fallbackTulaga manoa | fa'asologa 'fuli' Fa'ataga e fa'ailoa mai po'o fea le tulaga o le a fa'aogaina e Popper i tua. Mo nisi fa'amatalaga va'ai ile Popper.js's behavior docs
tuaoi manoa | elemene 'scrollParent' Fa'agata tapula'a tuaoi o le popover. Talia le taua o le 'viewport', 'window', 'scrollParent', poʻo se HTMLElement reference (JavaScript naʻo). Mo nisi fa'amatalaga va'ai ile Popper.js's preventOverflow docs .

Fa'amatalaga uiga mo popovers ta'itasi

O filifiliga mo popovers 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.

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 .

Va'ai la matou pepa JavaScript mo nisi fa'amatalaga.

$().popover(options)

E amata popovers mo se aoina elemene.

.popover('show')

Fa'aalia le popover o se elemene. Toe fo'i i le tagata vala'au a'o le'i fa'aalia le popover (fa'atusa a'o le'i tupu le shown.bs.popovermea na tupu). E manatu lenei mea o se "manual" faʻaosoina o le popover. Popovers o latou igoa ma anotusi e leai se umi e le fa'aalia.

$('#element').popover('show')

.popover('hide')

Natia le popover o se elemene. Toe fo'i i le tagata vala'au a'o le'i natia le popover (fa'atusa a'o le'i tupu le hidden.bs.popovermea na tupu). E manatu lenei mea o se "manual" faʻaosoina o le popover.

$('#element').popover('hide')

.popover('toggle')

Su'e le fa'apipi'i o se elemene. Toe fo'i i le tagata vala'au a'o le'i fa'aalia pe natia le popover (fa'atusa a'o le'i tupu le shown.bs.popoverpo'o le hidden.bs.popovermea na tupu). E manatu lenei mea o se "manual" faʻaosoina o le popover.

$('#element').popover('toggle')

.popover('dispose')

Natia ma fa'aumatia le popover o se elemene. Popovers e fa'aogaina le tu'uina atu (lea e faia e fa'aaoga ai le selectorfilifiliga ) e le mafai ona fa'aumatia ta'ito'atasi i elemene fa'aoso tupuaga.

$('#element').popover('dispose')

.popover('enable')

Tuuina atu i le popover o se elemene le mafai ona faʻaalia. Popovers e mafai ona fa'aletonu.

$('#element').popover('enable')

.popover('disable')

Aveese le avanoa e fa'aalia ai le popover o se elemene. Ole popover ole a mafai ona fa'aalia pe a toe fa'aagaina.

$('#element').popover('disable')

.popover('toggleEnabled')

Fa'asolo le avanoa e fa'aalia pe natia ai le popover o se elemene.

$('#element').popover('toggleEnabled')

.popover('update')

Fa'afou le tulaga o le popover o se elemene.

$('#element').popover('update')

Mea na tutupu

Ituaiga Mea Fa'amatalaga
show.bs.popover E mu vave lenei mea pe a showvalaʻau le auala faʻataʻitaʻiga.
fa'aalia.bs.popover O lenei mea e tupu pe a faʻaalia le popover i le tagata faʻaoga (o le a faʻatali mo suiga CSS e maeʻa).
hide.bs.popover O lenei mea na tupu e faʻamalo vave pe a hidevalaʻau le auala faʻataʻitaʻiga.
hidden.bs.popover O lenei mea e tupu pe a uma ona natia le popover mai le tagata faʻaoga (o le a faʻatali mo suiga CSS e maeʻa).
inserted.bs.popover O lenei mea na tupu e faʻamalo pe a maeʻa le show.bs.popovermea na tupu ina ua faʻapipiʻi le popover template i le DOM.
$('#myPopover').on('hidden.bs.popover', function () {
  // do something…
})