Jya ku bintu nyamukuru Jya kuri docs
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 .
  • 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-bs-togglekubiranga:

var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
  return new bootstrap.Popover(popoverTriggerEl)
})

Urugero: Ukoresheje containeramahitamo

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

var popover = new bootstrap.Popover(document.querySelector('.example-popover'), {
  container: 'body'
})

Urugero

<button type="button" class="btn btn-lg btn-danger" data-bs-toggle="popover" title="Popover title" data-bs-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. Icyerekezo kirimo indorerwamo mugihe ukoresheje Bootstrap muri RTL.

<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="top" data-bs-content="Top popover">
  Popover on top
</button>
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="right" data-bs-content="Right popover">
  Popover on right
</button>
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="bottom" data-bs-content="Bottom popover">
  Popover on bottom
</button>
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="left" data-bs-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 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-bs-toggle="popover" data-bs-trigger="focus" title="Dismissible popover" data-bs-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</a>
var popover = new bootstrap.Popover(document.querySelector('.popover-dismiss'), {
  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>, nibyiza byakozwe na clavier-yibanze ukoresheje tabindex="0".

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

<span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-content="Disabled popover">
  <button class="btn btn-primary" type="button" disabled>Disabled button</button>
</span>

Sass

Ibihinduka

$popover-font-size:                 $font-size-sm;
$popover-bg:                        $white;
$popover-max-width:                 276px;
$popover-border-width:              $border-width;
$popover-border-color:              rgba($black, .2);
$popover-border-radius:             $border-radius-lg;
$popover-inner-border-radius:       subtract($popover-border-radius, $popover-border-width);
$popover-box-shadow:                $box-shadow;

$popover-header-bg:                 shade-color($popover-bg, 6%);
$popover-header-color:              $headings-color;
$popover-header-padding-y:          .5rem;
$popover-header-padding-x:          $spacer;

$popover-body-color:                $body-color;
$popover-body-padding-y:            $spacer;
$popover-body-padding-x:            $spacer;

$popover-arrow-width:               1rem;
$popover-arrow-height:              .5rem;
$popover-arrow-color:               $popover-bg;

$popover-arrow-outer-color:         fade-in($popover-border-color, .05);

Ikoreshwa

Gushoboza popovers ukoresheje JavaScript:

var exampleEl = document.getElementById('example')
var popover = new bootstrap.Popover(exampleEl, options)

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 ibi bintu kubintu allowListbyemewe byemewe 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-bs-, Nka Muri data-bs-animation="". Witondere guhindura ubwoko bwurubanza rwamazina kuva kuri camelCase kuri kebab-urubanza mugihe utambutsa amahitamo ukoresheje ibiranga amakuru. Kurugero, aho gukoresha data-bs-customClass="beautifier", koresha data-bs-custom-class="beautifier".

Menya ko kubwimpamvu zumutekano the sanitize,, sanitizeFnhamwe allowListnamahitamo ntashobora gutangwa ukoresheje ibiranga amakuru.
Izina Andika Mburabuzi Ibisobanuro
animation boolean true Koresha CSS igenda ihinduka kuri popover
container umugozi | ikintu | ibinyoma false

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.

content umugozi | ikintu | imikorere ''

Mburabuzi agaciro agaciro niba data-bs-contentikiranga kidahari.

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

delay 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 false Shyiramo HTML muri popover. Niba ari ibinyoma, innerTextumutungo uzakoreshwa mugushyiramo ibiri muri DOM. Koresha inyandiko niba uhangayikishijwe n'ibitero bya XSS.
placement umugozi | imikorere 'right'

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.

selector umugozi | ibinyoma false Niba hatoranijwe uwatoranijwe, ibintu bya popover bizahabwa intego zagenwe. Mu myitozo, ibi bikoreshwa mugushoboza HTML ifite imbaraga kugirango hongerwe popovers. Reba ibi nurugero rwamakuru .
template umugozi '<div class="popover" role="tooltip"><div class="popover-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.

.popover-arrowbizahinduka umwambi wa popover.

Ikintu cyo gupfunyika hanze kigomba kugira urwego .popover.

title umugozi | ikintu | imikorere ''

Mburabuzi Umutwe Agaciro niba titleIkiranga kidahari.

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

trigger umugozi 'click' Uburyo popover iterwa - kanda | hover | kwibanda | imfashanyigisho. Urashobora gutsinda imbarutso nyinshi; kubatandukanya n'umwanya. manualntishobora guhuzwa nizindi mbarutso.
fallbackPlacements array ['top', 'right', 'bottom', 'left'] Sobanura ibyasubiwemo mugutanga urutonde rwibisobanuro (murwego rwo guhitamo). Kubindi bisobanuro reba imyitwarire ya popper
boundary umugozi | element 'clippingParents' Imipaka irenga imipaka ya popover (ikoreshwa gusa kuri popper yo gukumiraOverflow modifier). Mubusanzwe ni 'clippingParents'kandi irashobora kwemera HTMLElement (ukoresheje JavaScript gusa). Kubindi bisobanuro reba popper's detectOverflow docs .
customClass umugozi | imikorere ''

Ongeraho amasomo kuri popover iyo yerekanwe. Menya ko aya masomo azongerwaho hiyongereyeho ibyiciro byose byerekanwe mubishusho. Ongeraho ibyiciro byinshi, ubitandukanye numwanya : 'class-1 class-2'.

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

sanitize boolean true Gushoboza cyangwa guhagarika isuku. Nibikora 'template', 'content'kandi 'title'amahitamo azagira isuku. Reba igice cyisuku mubyangombwa byacu bya JavaScript .
allowList 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.
offset array | umugozi | imikorere [0, 8]

Offset ya popover ugereranije nintego yayo. Urashobora gutambutsa umurongo muri data ibiranga hamwe na koma yatandukanijwe indangagaciro nka:data-bs-offset="10,20"

Iyo imikorere ikoreshwa mukumenya offset, yitwa hamwe nikintu kirimo icyerekezo cya popper, icyerekezo, hamwe na popper ikosora nkibitekerezo byayo byambere. Ikintu gikurura DOM node yatambutse nkimpaka ya kabiri. Igikorwa kigomba gusubiza umurongo hamwe nimibare ibiri : .[skidding, distance]

Kubindi bisobanuro reba kuri popper ya offset .

popperConfig null | ikintu | imikorere null

Guhindura Bootstrap isanzwe ya Popper config, reba iboneza rya Popper .

Iyo imikorere ikoreshwa mugukora iboneza rya Popper, byitwa hamwe nikintu kirimo Bootstrap idasanzwe ya Popper. Iragufasha gukoresha no guhuza ibisanzwe hamwe nuburyo bwawe bwite. Imikorere igomba gusubiza ibintu byabugenewe kuri Popper.

Ibiranga amakuru kuri popovers kugiti cye

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

Gukoresha imikorere hamwepopperConfig

var popover = new bootstrap.Popover(element, {
  popperConfig: function (defaultBsPopperConfig) {
    // var newPopperConfig = {...}
    // use defaultBsPopperConfig if needed...
    // return newPopperConfig
  }
})

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 .

kwerekana

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

myPopover.show()

kwihisha

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

myPopover.hide()

guhinduranya

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

myPopover.toggle()

guta

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

myPopover.dispose()

Gushoboza

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

myPopover.enable()

guhagarika

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

myPopover.disable()

Guhindura

Kuzamura ubushobozi bwa popover yibintu kugirango yerekanwe cyangwa ihishe.

myPopover.toggleEnabled()

kuvugurura

Kuvugurura umwanya wibintu bya popover.

myPopover.update()

Kubona

Uburyo buhamye butuma ubona urugero rwa popover rujyanye nibintu bya DOM

var exampleTriggerEl = document.getElementById('example')
var popover = bootstrap.Popover.getInstance(exampleTriggerEl) // Returns a Bootstrap popover instance

GetOrCreateInstance

Uburyo buhamye butuma ubona urugero rwa popover rujyanye nibintu bya DOM, cyangwa gukora bundi bushya mugihe bitatangijwe

var exampleTriggerEl = document.getElementById('example')
var popover = bootstrap.Popover.getOrCreateInstance(exampleTriggerEl) // Returns a Bootstrap popover instance

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.
var myPopoverTrigger = document.getElementById('myPopover')
myPopoverTrigger.addEventListener('hidden.bs.popover', function () {
  // do something...
})