in English

Popovers

Dukumeenti iyo tusaaleyaal lagu daro Bootstrap popovers, sida kuwa laga helo iOS, shay kasta oo ku yaal boggaaga.

Dulmar

Waxyaabaha ay tahay in la ogaado marka la isticmaalayo popover plugin:

  • Popovers waxay ku tiirsan yihiin maktabadda xisbiga 3aad ee Popper meelaynta. Waa inaad ku dartaa popper.min.js ka hor bootstrap.js ama isticmaal bootstrap.bundle.min.js/ bootstrap.bundle.jska kooban Popper si ay popovers u shaqeeyaan!
  • Popovers waxay u baahan yihiin plugin tip -ku-tiirsanaan ahaan.
  • Haddii aad JavaScript-kayaga ka dhisayso isha, waxay u baahan tahayutil.js .
  • Popovers waxay u soo galeen sababo waxqabad dartood, marka waa inaad adigu bilawdaa .
  • Dhererka eber titleiyo contentqiyamku weligood ma muujin doonaan popover.
  • Qeex container: 'body'si aad uga fogaato soo jeedinta dhibaatooyinka qaybo badan oo kakan (sida kooxahayada wax gelinta, kooxaha badhanka, iwm).
  • Kicinta popovers ee walxaha qarsoon ma shaqayn doono.
  • Popovers .disabledama disabledcuriyayaasha waa in lagu kiciyo curiyaha duubka ah.
  • Marka uu ka kiciyo barroosinno isku duuban dhowr xariiq, popovers waxay dhexda u ahaan doonaan ballaca guud ee barroosinnada. Isticmaal s si .text-nowrapaad <a>uga fogaato dhaqankan.
  • Rabshadaha waa in la qariyaa ka hor inta aan laga saarin walxaha u dhigma ee DOM.
  • Popovers waa la kicin karaa iyada oo ay ugu wacan tahay shay ku jira hadhka DOM.
Sida caadiga ah, qaybtani waxay isticmaashaa nadiifiyaha ku dhex jira, kaas oo ka saara wax kasta oo HTML ah oo aan si cad loo ogolayn. Faahfaahin dheeraad ah ka eeg qaybta nadaafadda ee dukumeentiyada JavaScript .
Saamaynta animation ee qaybtani waxay ku xidhan tahay prefers-reduced-motionwaydiinta warbaahinta. Eeg qaybta dhaqdhaqaaqa la dhimay ee dukumeenti gelitaankeena .

Sii wad akhri si aad u aragto sida popovers ula shaqeeyaan tusaalooyinka qaarkood.

Tusaale: Dari popovers meel kasta

Hal dariiqo oo lagu bilaabi karo dhammaan popovers bogga waxay noqon kartaa in lagu xusho data-togglesifadooda:

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

Tusaale: Isticmaalka containerikhtiyaarka

Markaad haysatid qaabab qaar oo ah walxaha waalidka ee farageliya popover, waxaad u baahan doontaa inaad qeexdo caado containersi HTML popover's uu uga dhex muuqdo qaybtaas.

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

Tusaale

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

Afar jiho

Afar doorasho ayaa diyaar ah: sare, midig, hoose, iyo bidix oo toosan.

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

Ka saar marka xigta guji

Isticmaal focuskiciyeyaasha si aad u tirtirto popovers ee isticmaalaha gujinta xigta ee shay ka duwan curiyaha beddelka.

Calaamadayn gaar ah ayaa loo baahan yahay si loo joojiyo-ku-xigta-guji

Si aad u hesho hab-dhaqan iskutallaab ah oo ku habboon iyo hab-dhaqan-madal-madal ah, waa inaad isticmaashaa <a>summada, maaha summada , <button>sidoo kale waa inaad ku dartaa tabindexsifo.

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

Curiyayaasha naafada

Qaybaha sifada leh disabledma aha kuwo is dhexgal ah, taasoo la micno ah in isticmaalayaashu aanay kor u qaadi karin ama aanay gujin karin si ay u kiciyaan popover (ama qalab). Xakameyn ahaan, waxaad u baahan doontaa inaad ka kiciso popover ka duubka <div>ama <span>oo aad ka gudubto pointer-eventsqaybta naafada ah.

Kiciyeyaasha popover naafada, waxa kale oo aad doorbidi kartaa data-trigger="hover"si popover-ku ugu muuqdo jawaab celin muuqaal degdeg ah isticmaalayaashaada maadaama laga yaabo in aanay filanayn inay gujiyaan shay naafada ah.

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

Isticmaalka

U oggolow popovers iyada oo loo marayo JavaScript:

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

Popovers marmarka qaarkood waxay u muuqdaan kuwo wareersan Windows 10 aaladaha sababtoo ah dardargelinta GPU iyo nidaamka DPI oo la bedelay. Hawsha ka shaqaynta tan v4 waa in la joojiyo dardargelinta GPU sida loogu baahan yahay popovers-kaaga.

hagaajinta la soo jeediyay:

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

Samaynta popovers u shaqeyso kiiboodhka iyo isticmaalayaasha tignoolajiyada caawiya

Si loogu oggolaado isticmaaleyaasha kiiboodhka inay dhaqaajiyaan popovers-kaaga, waa inaad ku dartaa oo keliya curiyeyaasha HTML kuwaas oo dhaqan ahaan kiiboodhka diirada saaraya iyo is dhexgal (sida isku xidhka ama kontaroolada foomka). In kasta oo walxaha HTML-ka ah (sida <span>s) laga dhigi karo mid diiradda lagu saari karo iyadoo lagu darayo sifada tabindex="0", tani waxay ku dari doontaa joogsi laga yaabo inay dhibsato iyo jahawareer ku sameyso walxaha aan is dhex galka lahayn ee isticmaalayaasha kiiboodhka, iyo teknoolojiyadda caawinta badankoodu hadda kuma dhawaaqaan nuxurka popover ee xaaladdan. . Intaa waxaa dheer, ha isku hallayn oo kaliya hoverinay tahay kicinta popovers-kaaga, sababtoo ah tani waxay ka dhigaysaa kuwo aan suurtagal ahayn inay kiciyaan isticmaalayaasha kiiboodhka.

Inta aad geli karto hodan, habaysan HTML ee popovers oo leh htmlikhtiyaarka, waxaan si adag kuugula talineynaa inaad iska ilaaliso inaad ku darto qadar xad dhaaf ah oo ka kooban. Habka popovers hadda u shaqeeyaan waa in, marka la soo bandhigo, nuxurkoodu wuxuu ku xiran yahay curiyaha kiciya ee leh aria-describedbysifo. Natiijadu waxay tahay, dhammaan waxa ku jira popover-ka waxa lagu dhawaaqi doonaa isticmaalayaasha tignoolajiyada caawiya sidii hal socod dheer oo aan kala go' lahayn.

Intaa waxaa dheer, iyadoo ay suurtagal tahay in sidoo kale lagu daro kontaroolada is-dhexgalka (sida walxaha qaabka ama isku xidhka) popoverkaaga (adigoo ku daraya walxahan whiteListsifooyinka iyo calaamadaha la oggol yahay), ogow in wakhtigan popoverku aanu maamulin nidaamka diiradda saaraya kiiboodhka. Marka isticmaalaha kiiboodhka uu furo popover, diiradda ayaa hadhi doonta curiyaha kicinaya, iyo sida popover-ku inta badan aanu isla markiiba raacin kicinta ku jirta qaab dhismeedka dukumeentiga, ma jirto dammaanad qaadka in horay loo socdo/cadaadisTABwuxuu u guuri doonaa isticmaalaha kiiboodhka gudaha popover laftiisa. Marka la soo koobo, si fudud ku darida kontaroolada isdhexgalka ee popover waxay u badan tahay inay ka dhigto kontarooladan mid aan la heli karin/aan la isticmaali karin isticmaalayaasha kiiboodhka iyo isticmaalayaasha tignoolajiyada caawinta, ama ugu yaraan samaynta nidaamka guud ee diirada aan macquul ahayn. Xaaladahan, ka fiirso inaad isticmaasho qaab wada hadal ah.

Ikhtiyaarada

Ikhtiyaarada waxaa lagu gudbi karaa sifada xogta ama JavaScript. Sifooyinka xogta, ku dheji magaca ikhtiyaarka data-, sida ku jira data-animation="".

Ogsoonow in sababo ammaan dartood sanitize, sanitizeFniyo whiteListikhtiyaarrada aan lagu bixin karin iyadoo la adeegsanayo sifooyinka xogta.
Magaca Nooca Asal ahaan Sharaxaada
animation booliyan run Codso u gudbida libdhicida CSS ilaa popover
weel xadhig | element | been ah been ah

Ku dhejinta popover-ka shay gaar ah. Tusaale container: 'body':. Doorashadani waxay si gaar ah faa'iido u leedahay inay kuu ogolaato inaad ku dhejiso qulqulka qulqulka dukumeentiga u dhow curiyaha kiciya - kaas oo ka ilaalin doona popover inuu ka sababbeeyo walxaha kiciya inta lagu jiro cabbirka daaqada.

nuxurka xadhig | element | shaqayn ''

Qiimaha nuxurka asalka ah haddii data-contentsifadu aanay jirin.

Haddii shaqo la bixiyo, waxaa loogu yeeraa iyada oo thistixraaceeda lagu dhejiyay curiyaha popover-ku ku dheggan yahay.

dib u dhac lambarka | walax 0

Dib u dhigista muujinta iyo qarinta popover (ms) - kuma khusayso nooca kiciya gacanta

Haddii nambar la keeno, dib u dhac ayaa lagu dabaqayaa qarinta/muujinta labadaba

Qaab dhismeedka shaygu waa:delay: { "show": 500, "hide": 100 }

html booliyan been ah Geli HTML-ka popover-ka Haddii ay been tahay, texthabka jQuery ayaa loo isticmaali doonaa in la geliyo macluumaadka DOM. Isticmaal qoraal haddii aad ka welwelsan tahay weerarrada XSS.
meelaynta xadhig | shaqayn 'sax'

Sida loo dhigo popover - auto | sare | hoose | bidix | xaq.
Marka autola cayimo, waxay si firfircoon u jihayn doontaa popover-ka.

Marka hawl loo isticmaalo si loo go'aamiyo meelaynta, waxaa lagu magacaabaa node popover DOM oo ah dooddeeda kowaad iyo curiyaha DOM node oo ah kan labaad. Macnaha thisguud waxa loo dejiyay tusaale popover.

dooriye xadhig | been ah been ah Haddii doorasho la bixiyo, shayada soo-bandhigista waxa loo igmaday bartilmaameedyada la cayimay. Ficil ahaan, tan waxaa loo istcimaalaa in lagu suurtageliyo nuxurka HTML ee firfircoon in lagu daro popovers. Bal tan iyo tusaale wargelin ah eeg .
template xadhig '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>'

HTML saldhig si loo isticmaalo marka la abuurayo popover.

Popover's titleayaa lagu duri doonaa .popover-header.

Popover's contentayaa lagu duri doonaa .popover-body.

.arrowwaxay noqon doontaa fallaadha popover.

Cutubka duubka ugu dambeeya waa inuu lahaadaa .popoverfasalka.

horyaalka xadhig | element | shaqayn ''

Qiimaha cinwaanka caadiga ah haddii titlesifadu aanay jirin.

Haddii shaqo la bixiyo, waxaa loogu yeeraa iyada oo thistixraaceeda lagu dhejiyay curiyaha popover-ku ku dheggan yahay.

kicin xadhig 'guji' Sida popover u kiciyo - guji | dullid | diiradda | buug-gacmeedka. Waxaad ka gudbi kartaa kiciyeyaasha badan; meel bannaan ku kala saar. manuallaguma dari karo kiciye kale.
dhimis lambarka | xadhig 0 Deminta popover marka loo eego bartilmaameedka. Macluumaad dheeraad ah ka eeg dukumeentiyada dhimista ee Popper .
fallbackPlacement xadhig | diyaarin 'rogid' Oggolow inuu caddeeyo booska Popper uu isticmaali doono dib-u-dhaca. Wixii macluumaad dheeraad ah tixraac dukumeentiyada dhaqanka Popper
CustomClass xadhig | shaqayn ''

Casharo ku dar popover marka la muujiyo. Ogsoonow in fasalladan lagu dari doono marka lagu daro fasal kasta oo lagu qeexay qaab-dhismeedka. Si loogu daro fasalo badan, ku kala saar meelo banaan: 'a b'.

Waxa kale oo aad gudbin kartaa hawl soo celinaysa hal xadhig oo ay ku jiraan magacyo dheeraad ah.

xuduud xadhig | curiye 'kor u qaadida waalidka' Xadka xad-dhaafka ah ee xaddidaadda popover. Aqbala qiyamka 'viewport', 'window', 'scrollParent', ama tixraaca HTMLElement (JavaScript kaliya). Macluumaad intaas ka badan waxaad eegtaa dukumeentiyada Popper ee ka hortagga qulqulka .
nadaafadda booliyan run Daar ama dami nadaafadda Haddii la hawlgeliyo 'template', 'content'iyo 'title'fursadaha waa la nadiifin doonaa. Ka eeg qaybta nadaafadda ee dukumeentiyada JavaScript .
Liis cad walax Qiimaha caadiga ah Shayga oo ka kooban sifooyin iyo calaamado la oggol yahay
nadaafaddaFn waxba | shaqayn waxba Halkan waxa aad ku keeni kartaa shaqadaada nadaafadda. Tani waxay noqon kartaa mid faa'iido leh haddii aad doorbidayso inaad isticmaasho maktabad gaar ah si aad u sameyso nadaafadda.
popperConfig waxba | walax waxba Si aad u bedesho Bootstrap's default Popper config, arag qaabka Popper

Sifooyinka xogta ee popovers shaqsi

Ikhtiyaarada popovers shakhsi ahaan waxaa lagu qeexi karaa iyada oo la isticmaalayo sifooyin xogta, sida kor lagu sharaxay.

Hababka

Hababka iyo kala-guurka aan isku midka ahayn

Dhammaan hababka API waa isku mid waxayna bilaabaan kala-guurka . Waxay ku soo noqdaan qofka soo wacaya isla markii uu bilaabmo kala-guurka laakiin ka hor inta uusan dhammaan . Intaa waxaa dheer, hab ku baaqaya in qayb ka beddelka waa la iska indhatiray .

Ka eeg dukumeentiyada JavaScript wixii macluumaad dheeraad ah .

$().popover(options)

Wuxuu u bilaabaa popovers ururinta curiyaha.

.popover('show')

Waxay daaha ka qaadaysaa soo boodada curiyaha Ku soo noqoshada soo wacaha ka hor inta aan si dhab ah loo muujin popover (tusaale ka hor intaanay shown.bs.popoverdhacdada dhicin). Tan waxa loo tixgaliyaa "buuga" kicinta popover. Popovers oo cinwaankoodu iyo nuxurkooduba yahay eber-dheer weligood lama soo bandhigin.

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

.popover('hide')

Wuxuu qariyaa boodboodka curiyaha. Ku soo noqoshada soo wacaha ka hor inta aan bood-boodka dhab ahaantii la qarin (ie ka hor intaanay hidden.bs.popoverdhacdada dhicin). Tan waxa loo tixgaliyaa "buuga" kicinta popover.

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

.popover('toggle')

Beddelaa soo boodada curiyaha Ku soo noqda qofka soo wacaya ka hor inta aan bood-boodka dhab ahaantii la muujin ama la qarin (tusaale ka hor inta aanay dhacdada shown.bs.popoverama hidden.bs.popoverdhacdada dhicin). Tan waxa loo tixgaliyaa "buuga" kicinta popover.

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

.popover('dispose')

Qariyaa oo baabi'iyaa popover element. Popovers isticmaala ergada (kuwaas oo la abuuray iyadoo la isticmaalayo ikhtiyaarka selector) si gaar ah looma baabi'in karo walxaha kiciya faraca.

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

.popover('enable')

Siinaya popover element awood lagu muujiyo. Popovers waa la dajiyay si toos ah.

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

.popover('disable')

Waxay meesha ka saartaa awoodda soo-bandhigidda curiyaha si loo muujiyo. Booqashada ayaa la tusi karaa oo keliya haddii dib loo hawlgeliyo.

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

.popover('toggleEnabled')

Waxay beddeshaa awoodda boodboodka curiyaha si loo muujiyo ama loo qariyo.

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

.popover('update')

Waxay cusboonaysiisaa booska boodboodka curiyaha.

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

Dhacdooyinka

Nooca Dhacdada Sharaxaada
show.bs.popover Dhacdadani waxay isla markaaba gubataa marka showhabka tusaalaha la yiraahdo.
la tusay.bs.popover Dhacdadan waxa la eryaa marka popover-ka laga dhigo mid la arki karo isticmaaluhu (waxay sugi doontaa inta uu CSS ka gudbayo dhamaystirka).
qari.bs.popover Dhacdadan ayaa isla markaaba la eryaa marka hidehabka tusaale ahaan loo waco.
qarsoon.bs.popover Dhacdadan waxa la eryaa marka popover uu dhammeeyo in laga qariyo isticmaalaha (waxa ay sugi doontaa inta uu CSS ka gudbayo dhamaystirka).
la geliyey.bs.popover Dhacdadan ayaa la eryaa dhacdada ka dib show.bs.popovermarka qaabka popover lagu daray DOM.
$('#myPopover').on('hidden.bs.popover', function () {
  // do something...
})