in English

Amashanyarazi

Inyandiko n'ingero zo kongera Bootstrap popovers, nkibisangwa muri iOS, kubintu byose kurubuga rwawe.

Incamake

Ibintu ugomba kumenya mugihe ukoresheje plugin ya popover:

  • Popovers yisunga isomero ryishyaka rya 3 Popper kugirango ihagarare. Ugomba gushyiramo popper.min.js mbere ya bootstrap.js cyangwa gukoresha bootstrap.bundle.min.js/ bootstrap.bundle.jsirimo Popper kugirango popovers ikore!
  • Popovers isaba ibikoresho bya plugin nkibisabwa .
  • Niba wubaka JavaScript yacu kuva isoko, birasabautil.js .
  • Popovers ihitamo kubwimpamvu zikorwa, ugomba rero kubitangiza wenyine .
  • Uburebure bwa zeru titlen'indangagaciro contentntibizigera byerekana popover.
  • Kugaragaza container: 'body'kugirango wirinde gutanga ibibazo mubice byinshi bigoye (nkitsinda ryacu ryinjiza, amatsinda ya buto, nibindi).
  • Gukurura popovers kubintu byihishe ntabwo bizakora.
  • Popovers ya .disabledcyangwa disabledibintu bigomba gukururwa kubintu bipfunyika.
  • Iyo bivuye ku byuma bifunga imirongo myinshi, popovers izaba hagati yubugari bwa rusange. Koresha .text-nowrapkuri <a>s kugirango wirinde iyi myitwarire.
  • Popovers igomba guhishwa mbere yuko ibintu bihuye bivanwa muri DOM.
  • Popovers irashobora gukururwa bitewe nikintu kiri imbere mu gicucu DOM.
Mburabuzi, iki gice gikoresha ibikoresho byubatswe mu isuku, bikuraho ibintu byose bya HTML bitemewe. Reba igice cyisuku mubisobanuro byacu bya JavaScript kugirango ubone ibisobanuro birambuye.
Ingaruka ya animasiyo yibi bice biterwa prefers-reduced-motionnibibazo byitangazamakuru. Reba igice cyagabanijwe cyicyiciro cyibisobanuro byacu .

Komeza usome kugirango urebe uko popovers ikora hamwe ningero zimwe.

Urugero: Gushoboza popovers ahantu hose

Uburyo bumwe bwo gutangiza popovers zose kurupapuro kwaba ari uguhitamo data-togglekubiranga:

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

Urugero: Ukoresheje containeramahitamo

Mugihe ufite uburyo bumwe kubintu byababyeyi bibangamira popover, uzashaka kwerekana imigenzo containerkugirango HTML ya popover igaragara muri kiriya kintu aho.

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

Urugero

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

Ibyerekezo bine

Amahitamo ane arahari: hejuru, iburyo, hepfo, n'ibumoso.

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

Kwirukana gukanda

Koresha focusimbarutso kugirango wirukane popovers kumukoresha ukurikiraho ibintu bitandukanye kuruta guhinduranya.

Ikimenyetso cyihariye gisabwa kugirango wirukanwe-gukurikira-gukanda

Kuburyo bukwiye bwambukiranya-mbuga hamwe nimyitwarire ya cross-platform, ugomba gukoresha <a>tagi, ntabwo ari <button>tagi, kandi ugomba no gushyiramo tabindexikiranga.

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

Ibintu byahagaritswe

Ibintu bifite disabledikiranga ntabwo bikorana, bivuze ko abakoresha badashobora kugendagenda cyangwa kubikanda kugirango batere popover (cyangwa ibikoresho). Nkumurimo wakazi, uzakenera gukurura popover uhereye kumuzingo <div>cyangwa <span>hanyuma ukarenga pointer-eventskuri element yamugaye.

Kubimuga byahagaritswe byimikorere, urashobora kandi guhitamo data-trigger="hover"kugirango popover igaragara nkibisubizo byihuse kubakoresha nkuko badashobora gutegereza gukanda kubintu bimugaye.

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

Ikoreshwa

Gushoboza popovers ukoresheje JavaScript:

$('#example').popover(options)
Kwihuta kwa GPU

Popovers rimwe na rimwe igaragara nabi ku bikoresho bya Windows 10 kubera kwihuta kwa GPU hamwe na sisitemu DPI yahinduwe. Igikorwa cyibi muri v4 nuguhagarika kwihuta kwa GPU nkuko bikenewe kuri popovers yawe.

Igitekerezo cyo gukosora:

Popper.Defaults.modifiers.computeStyle.gpuAcceleration = !(window.devicePixelRatio < 1.5 && /Win/.test(navigator.platform))

Gukora popovers ikora kuri clavier hamwe nabafasha gukoresha ikoranabuhanga

Kwemerera abakoresha clavier gukora enterineti yawe, ugomba kubongerera gusa kubintu bya HTML bisanzwe bisanzwe byibanze-byibanda kandi bigakorana (nkumuhuza cyangwa kugenzura imiterere). Nubwo ibice bya HTML uko bishakiye (nka <span>s) bishobora gukorwa byibandwaho mukongeramo tabindex="0"ikiranga, ibi bizongeramo ibishoboka birakaze kandi bitera urujijo guhagarika ibintu bidahuza abakoresha clavier, kandi tekinoroji ifasha muri iki gihe ntabwo itangaza ibiri muri popover muriki kibazo . Byongeye kandi, ntukishingikirize gusa hovernkimbarutso ya popovers yawe, kuko ibi bizatuma badashobora gukurura abakoresha clavier.

Mugihe ushobora gushyiramo HTML ikungahaye, yubatswe muri popovers hamwe namahitamo html, turagusaba cyane ko wirinda kongeramo ibintu birenze urugero. Uburyo popovers ikora kurubu nuko, iyo imaze kugaragara, ibiyirimo bihujwe na trigger element hamwe na aria-describedbykiranga. Nkigisubizo, ibyuzuye muri popover bizatangazwa kugirango bifashe abakoresha ikoranabuhanga nkumugezi muremure, udahagarara.

Ikigeretse kuri ibyo, mugihe bishoboka ko ushiramo no kugenzura ibikorwa (nkibintu bigize imiterere cyangwa amahuza) muri popover yawe (wongeyeho ibyo bintu kuri whiteListcyangwa byemewe ibiranga na tagi), menya ko kuri ubu popover idacunga urutonde rwibanda kuri clavier. Iyo umukoresha wa clavier afunguye popover, intumbero iguma kubintu bitera, kandi nkuko popover idahita ikurikira imbarutso mumiterere yinyandiko, nta garanti yerekana ko gutera imbere / gukandaTABKwimura umukoresha wa clavier muri popover ubwayo. Muri make, gusa wongeyeho igenzura ryimikorere kuri popover birashoboka ko ibyo bigenzurwa bitagerwaho / bidakoreshwa kubakoresha clavier hamwe nabakoresha tekinoroji ifasha, cyangwa byibuze gukora kubitekerezo bidafite ishingiro muri rusange. Muri ibi bihe, tekereza gukoresha uburyo bwo kuganira.

Amahitamo

Amahitamo arashobora kunyuzwa kumurongo wamakuru cyangwa JavaScript. Kubiranga Ibyatanzwe, Ongeraho Ihitamo Izina Kuri data-, Nka Muri data-animation="".

Menya ko kubwimpamvu z'umutekano the sanitize, sanitizeFnn'amahitamo whiteListntashobora gutangwa ukoresheje ibiranga amakuru.
Izina Andika Mburabuzi Ibisobanuro
animasiyo boolean ni ukuri Koresha CSS igenda ihinduka kuri popover
kontineri umugozi | ikintu | ibinyoma ibinyoma

Ongeraho popover kubintu runaka. Urugero : container: 'body'. Ihitamo ningirakamaro cyane kuberako igufasha gushyira popover mugutemba kwinyandiko hafi yikintu gikurura - bizarinda popover kureremba kure yikintu gikurura mugihe idirishya rinini.

ibirimo umugozi | ikintu | imikorere ''

Mburabuzi agaciro agaciro niba data-contentikiranga kidahari.

Niba imikorere yatanzwe, izahamagarwa hamwe thisnibisobanuro byayo kuri element popover ifatanye.

gutinda umubare | ikintu 0

Gutinda kwerekana no guhisha popover (ms) - ntabwo ikoreshwa muburyo bwintoki

Niba umubare watanzwe, gutinda gukoreshwa byombi guhisha / kwerekana

Imiterere yibintu ni:delay: { "show": 500, "hide": 100 }

html boolean ibinyoma Shyiramo HTML muri popover. Niba ari ibinyoma, uburyo bwa jQuery textbuzakoreshwa mugushyiramo ibintu muri DOM. Koresha inyandiko niba uhangayikishijwe n'ibitero bya XSS.
gushyira umugozi | imikorere 'iburyo'

Nigute ushobora gushira popover - auto | hejuru | munsi | ibumoso | iburyo.
Iyo autobisobanuwe neza, bizagenda byerekeza kuri popover.

Iyo imikorere ikoreshwa mukumenya aho ishyirwa, byitwa hamwe na popover DOM node nkibitekerezo byayo byambere hamwe na elementing DOM node nkibya kabiri. Imirongo thisyashyizweho kuri popover urugero.

uwatoranije umugozi | ibinyoma ibinyoma Niba hatoranijwe uwatoranijwe, ibintu bya popover bizahabwa intego zagenwe. Mubimenyerezo, ibi bikoreshwa mugushoboza HTML yingirakamaro kugirango hongerwe popovers. Reba ibi nurugero rwamakuru .
Inyandikorugero umugozi '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>'

Shingiro HTML yo gukoresha mugihe uremye popover.

Ibya popover titlebizaterwa muri .popover-header.

Ibya popover contentbizaterwa muri .popover-body.

.arrowbizahinduka umwambi wa popover.

Ikintu cyo gupfunyika hanze kigomba kugira urwego .popover.

Umutwe umugozi | ikintu | imikorere ''

Mburabuzi Umutwe Agaciro niba titleIkiranga kidahari.

Niba imikorere yatanzwe, izahamagarwa hamwe thisnibisobanuro byayo kuri element popover ifatanye.

imbarutso umugozi 'kanda' Uburyo popover iterwa - kanda | hover | kwibanda | imfashanyigisho. Urashobora gutsinda imbarutso nyinshi; kubatandukanya n'umwanya. manualntishobora guhuzwa nizindi mbarutso.
offset umubare | umugozi 0 Offset ya popover ugereranije nintego yayo. Kubindi bisobanuro reba kuri popper ya offset .
Gusubira inyuma umugozi | array 'flip' Emera kwerekana umwanya Popper azakoresha mugusubira inyuma. Kubindi bisobanuro reba imyitwarire ya Popper
Umukiriya umugozi | imikorere ''

Ongeraho amasomo kuri popover iyo yerekanwe. Menya ko aya masomo azongerwaho hiyongereyeho ibyiciro byose byerekanwe mubishusho. Ongeraho ibyiciro byinshi, ubitandukanye numwanya : 'a b'.

Urashobora kandi gutambutsa imikorere igomba gusubiza umurongo umwe urimo amazina yinyongera.

imbibi umugozi | element 'umuzingoParent' Kurenga imipaka imipaka ya popover. Emera indangagaciro za ,,, 'viewport'cyangwa HTMLElement yerekana (JavaScript gusa). Kubindi bisobanuro reba Popper's gukumiraOverflow docs .'window''scrollParent'
kugira isuku boolean ni ukuri Gushoboza cyangwa guhagarika isuku. Nibikora 'template', 'content'kandi 'title'amahitamo azagira isuku. Reba igice cyisuku mubyangombwa byacu bya JavaScript .
Urutonde ikintu Agaciro gasanzwe Ikintu kirimo ibiranga byemewe na tagi
sanitizeFn null | imikorere null Hano urashobora gutanga imikorere yawe yisuku. Ibi birashobora kuba ingirakamaro niba uhisemo gukoresha isomero ryabigenewe kugirango ukore isuku.
popperConfig null | ikintu null Guhindura Bootstrap isanzwe ya Popper config, reba iboneza rya Popper

Ibiranga amakuru kuri popovers kugiti cye

Amahitamo ya popovers kugiti cye arashobora kugaragazwa muburyo bwo gukoresha ibiranga amakuru, nkuko byasobanuwe haruguru.

Uburyo

Uburyo butajegajega ninzibacyuho

Inzira zose za API ntizihuza kandi zitangira inzibacyuho . Basubira kumuhamagara mugihe inzibacyuho itangiye ariko itararangira . Mubyongeyeho, uburyo bwo guhamagarira ibice byinzibacyuho bizirengagizwa .

Reba inyandiko zacu za JavaScript kubindi bisobanuro .

$().popover(options)

Itangiza popovers yikintu cyo gukusanya.

.popover('show')

Kugaragaza ikintu cya popover. Garuka kumuhamagara mbere yuko popover yerekanwe mubyukuri (nukuvuga mbere yuko shown.bs.popoveribyabaye biba). Ibi bifatwa nk "intoki" itera popover. Popovers ifite umutwe nibirimo byombi zeru-uburebure ntibigaragara.

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

.popover('hide')

Hisha ikintu cya popover. Garuka kumuhamagara mbere yuko popover ihishwa mubyukuri (nukuvuga mbere yuko hidden.bs.popoveribyabaye biba). Ibi bifatwa nk "intoki" itera popover.

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

.popover('toggle')

Kuzuza ikintu cya popover. Garuka kumuhamagaye mbere yuko popover yerekanwe cyangwa yihishe (nukuvuga mbere yuko ibyabaye shown.bs.popovercyangwa hidden.bs.popoveribyabaye bibaho). Ibi bifatwa nk "intoki" itera popover.

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

.popover('dispose')

Hisha kandi usenye ikintu cya popover. Popovers ikoresha delegasiyo (yashizweho hakoreshejwe amahitamoselector ) ntishobora gusenywa kugiti cye kubintu bikomokaho .

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

.popover('enable')

Itanga ikintu cya popover ubushobozi bwo kwerekanwa. Popovers ishoboye kubisanzwe.

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

.popover('disable')

Kuraho ubushobozi bwa popover yibintu kugirango yerekanwe. Popover izashobora kwerekanwa gusa niba yongeye gukora.

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

.popover('toggleEnabled')

Kuzamura ubushobozi bwa popover yibintu kugirango yerekanwe cyangwa ihishe.

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

.popover('update')

Kuvugurura umwanya wibintu bya popover.

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

Ibyabaye

Ubwoko bwibyabaye Ibisobanuro
kwerekana.bs Ibirori birasa ako kanya mugihe showurugero rwitwa.
yerekanwe.bs Ibirori birukanwa mugihe popover yakozwe igaragara kubakoresha (izategereza ko inzibacyuho ya CSS irangira).
guhisha.bs Ibi birori birahita bisohoka mugihe uburyo hidebwurugero bwahamagawe.
bihishe.bs Ibirori birukanwa mugihe popover yarangije guhishwa uyikoresha (azategereza ko inzibacyuho ya CSS irangira).
Byinjijwe.bs Ibirori birukanwe nyuma show.bs.popoveryibyabaye mugihe icyitegererezo cya popover cyongewe kuri DOM.
$('#myPopover').on('hidden.bs.popover', function () {
  // do something...
})