Popovers
Zolemba ndi zitsanzo zowonjezerera ma popover a Bootstrap, monga omwe amapezeka mu iOS, pazinthu zilizonse patsamba lanu.
Mwachidule
Zomwe muyenera kudziwa mukamagwiritsa ntchito pulogalamu ya popover:
- Popovers amadalira laibulale ya chipani chachitatu Popper kuti akhazikike. Muyenera kuphatikiza popper.min.js pamaso pa bootstrap.js kapena gwiritsani ntchito
bootstrap.bundle.min.js
/bootstrap.bundle.js
yomwe ili ndi Popper kuti popovers agwire ntchito! - Popovers amafuna chida chowonjezera ngati chodalira.
- Ngati mukupanga JavaScript yathu kuchokera kugwero, pamafunika
util.js
. - Ma Popover amasankha kulowa pazifukwa zogwirira ntchito, chifukwa chake muyenera kuziyambitsa nokha .
- Ziro-utali
title
ndicontent
zikhalidwe sizidzawonetsa popover. - Nenani
container: 'body'
kuti mupewe kupereka zovuta muzinthu zovuta kwambiri (monga magulu athu olowetsa, magulu a batani, ndi zina). - Kuyambitsa popover pazinthu zobisika sikungagwire ntchito.
- Popovers
.disabled
kapenadisabled
zinthu ziyenera kuyambitsidwa pa chinthu chomata. - Akayambika kuchokera ku anangula omwe amazungulira mizere ingapo, ma popovers amakhala pakati pa nangula wonsewo. Gwiritsani
.text-nowrap
ntchito zanu<a>
kuti mupewe izi. - Popovers ayenera kubisidwa zinthu zawo zofananira zisanachotsedwe mu DOM.
- Popovers amatha kuyambika chifukwa cha chinthu chomwe chili mkati mwa mthunzi wa DOM.
prefers-reduced-motion
funso la media. Onani gawo
lochepetsedwa la zolemba zathu zofikira .
Pitilizani kuwerenga kuti muwone momwe popover amagwirira ntchito ndi zitsanzo zina.
Chitsanzo: Atseguleni mapopozi paliponse
Njira imodzi yokhazikitsira ma popover onse patsamba ingakhale kuwasankha malinga ndi zomwe data-toggle
ali:
$(function () {
$('[data-toggle="popover"]').popover()
})
Chitsanzo: Kugwiritsa ntchito container
njira
Mukakhala ndi masitaelo pa chinthu cha makolo chomwe chimasokoneza popover, mudzafuna kufotokoza mwambo container
kuti HTML ya popover iwonekere mkati mwa chinthucho.
$(function () {
$('.example-popover').popover({
container: 'body'
})
})
Chitsanzo
<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>
Njira zinayi
Zosankha zinayi zilipo: pamwamba, kumanja, pansi, ndi kumanzere.
<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>
Chotsani mukadina kwina
Gwiritsani ntchito focus
choyambitsacho kuti muchotse zotulukapo pakadina kotsatira kwa wogwiritsa wa chinthu china kusiyana ndi chinthu chosinthira.
Chizindikiro china chofunikira pakuchotsa-pa-kudina-kotsatira
Kuti mugwiritse ntchito msakatuli woyenera komanso papulatifomu, muyenera kugwiritsa ntchito tag <a>
, osati<button>
tag, komanso muyenera kuphatikizanso mawonekedwe tabindex
.
<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'
})
Zinthu zolemala
Zinthu zomwe zili ndi mawonekedwe disabled
ake sizimalumikizana, kutanthauza kuti ogwiritsa ntchito sangasunthe kapena kuzidina kuti ayambitse popover (kapena chida). Monga njira yogwirira ntchito, mudzafuna kuyambitsa popover kuchokera ku wrapper <div>
kapena <span>
ndikuwongolera zomwe pointer-events
zili olumala.
Pazinthu zoyambitsa popover zolemala, mungakondenso data-trigger="hover"
kuti popover iwoneke ngati malingaliro apompopompo kwa ogwiritsa ntchito anu chifukwa sangayembekezere kudina chinthu cholemala.
<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>
Kugwiritsa ntchito
Yambitsani popover kudzera pa JavaScript:
$('#example').popover(options)
Kuchulukitsa kwa GPU
Popovers nthawi zina amawoneka osamveka Windows 10 zida chifukwa cha mathamangitsidwe a GPU ndi DPI yosinthidwa. Njira yopangira izi mu v4 ndikuletsa kuthamangitsa kwa GPU ngati pakufunika pama popovers anu.
Kukonza komwe kumaperekedwa:
Popper.Defaults.modifiers.computeStyle.gpuAcceleration = !(window.devicePixelRatio < 1.5 && /Win/.test(navigator.platform))
Kupanga ma popover ntchito kwa ogwiritsa ntchito kiyibodi ndi ukadaulo wothandizira
Kuti mulole ogwiritsa ntchito kiyibodi kuti ayambitse ma popovers anu, muyenera kungowonjezera kuzinthu za HTML zomwe nthawi zambiri zimakhala zokhazikika komanso zolumikizana (monga maulalo kapena zowongolera mawonekedwe). Ngakhale zinthu zosasinthika za HTML (monga <span>
s) zitha kukhala zowoneka bwino powonjezera mawonekedwe tabindex="0"
, izi ziwonjezera zoyimitsa zosokoneza komanso zosokoneza pazinthu zomwe sizimalumikizana ndi ogwiritsa ntchito kiyibodi, ndipo matekinoloje othandizira ambiri pakadali pano salengeza zomwe zili mu popover pakadali pano. . Kuphatikiza apo, musadalire hover
ngati choyambitsa ma popover anu, chifukwa izi zipangitsa kuti zikhale zosatheka kuyambitsa ogwiritsa ntchito kiyibodi.
Ngakhale mutha kuyika ma HTML olemera, opangidwa ndi ma popover ndi html
mwayi, tikupangira kuti mupewe kuwonjezera kuchuluka kwazinthu. Momwe ma popovers amagwirira ntchito pano ndikuti, zikawonetsedwa, zomwe zili ndizomwe zimalumikizidwa ndi zomwe aria-describedby
zimayambira. Zotsatira zake, zonse zomwe zili mu popover zidzalengezedwa kwa ogwiritsa ntchito ukadaulo wothandizira ngati mtsinje umodzi wautali, wosasokonezeka.
Kuphatikiza apo, ngakhale ndikothekanso kuphatikiza zowongolera (monga mawonekedwe amtundu kapena maulalo) mu popover yanu (powonjezera zinthu izi whiteList
kapena zololedwa ndi ma tag), dziwani kuti pakadali pano popover samayang'anira dongosolo la kiyibodi. Wogwiritsa ntchito kiyibodi akatsegula popover, kuyang'ana kumakhalabe pazomwe zikuyambitsa, ndipo monga momwe popover nthawi zambiri samatsata choyambitsacho pamapangidwe a chikalatacho, palibe chitsimikizo kuti kupita patsogolo / kukanikiza.TABidzasuntha wogwiritsa ntchito kiyibodi mu popover yokha. Mwachidule, kungowonjezera maulamuliro olumikizana ku popover kungapangitse zowongolerazi kukhala zosafikirika/zosagwiritsidwa ntchito kwa ogwiritsa ntchito kiyibodi ndi ogwiritsa ntchito matekinoloje othandizira, kapena kupanga dongosolo losamveka bwino. Muzochitika izi, lingalirani kugwiritsa ntchito dialog ya modal m'malo mwake.
Zosankha
Zosankha zitha kuperekedwa kudzera pa data kapena JavaScript. Pamawonekedwe a data, yonjezerani dzina lachisankho ku data-
, monga mu data-animation=""
.
sanitize
,
sanitizeFn
ndi
whiteList
zosankha sizingaperekedwe pogwiritsa ntchito mawonekedwe a data.
Dzina | Mtundu | Zosasintha | Kufotokozera |
---|---|---|---|
makanema ojambula | boolean | zoona | Ikani kusintha kwa CSS fade ku popover |
chotengera | chingwe | chinthu | zabodza | zabodza | Imawonjezera popover ku chinthu china. Chitsanzo: |
zomwe zili | chingwe | chinthu | ntchito | '' | Mtengo wosiyidwa wazinthu ngati Ngati ntchito yaperekedwa, |
kuchedwa | nambala | chinthu | 0 | Kuchedwa kusonyeza ndi kubisa popover (ms) - sikugwira ntchito pamanja choyambitsa mtundu Ngati nambala yaperekedwa, kuchedwetsa kumayikidwa pazithunzi zonse ziwiri Kapangidwe kachinthu ndi: |
html | boolean | zabodza | Ikani HTML mu popover. Ngati zabodza, text njira ya jQuery idzagwiritsidwa ntchito kuyika zomwe zili mu DOM. Gwiritsani ntchito mawu ngati mukuda nkhawa ndi kuukira kwa XSS. |
kuika | chingwe | ntchito | 'chabwino' | Momwe mungayikitsire popover - auto | pamwamba | pansi | kumanzere | kulondola. Ntchito ikagwiritsidwa ntchito kudziwa malo, imatchedwa ndi popover DOM node ngati mkangano wake woyamba komanso chinthu choyambitsa DOM node ngati yachiwiri. Nkhaniyi |
wosankha | chingwe | zabodza | zabodza | Ngati chosankha chaperekedwa, zinthu za popover zidzaperekedwa ku zomwe zafotokozedwazo. M'malo mwake, izi zimagwiritsidwa ntchito kuti zithandizire HTML zomwe zili ndi ma popover awonjezedwe. Onani izi ndi chitsanzo chodziwitsa . |
template | chingwe | '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>' |
Base HTML kuti mugwiritse ntchito popanga popover. Ma popover adzabayidwa Ma popover adzabayidwa
Chokulunga chakunja chiyenera kukhala ndi |
mutu | chingwe | chinthu | ntchito | '' | Mtengo wamutu wotsikirapo ngati Ngati ntchito yaperekedwa, |
choyambitsa | chingwe | 'dinani' | Momwe popover imayambira - dinani | kugwa | kuganizira | buku. Mutha kudutsa zoyambitsa zambiri; alekanitse iwo ndi danga. manual sichingaphatikizidwe ndi choyambitsa china chilichonse. |
kuchepetsa | nambala | chingwe | 0 | Kuchepetsa kwa popover mogwirizana ndi cholinga chake. Kuti mumve zambiri onani za Popper's offset docs . |
fallbackPlacement | chingwe | gulu | 'tembenuzani' | Lolani kutchula malo omwe Popper adzagwiritse ntchito pobwerera. Kuti mumve zambiri onani zolemba za Popper's behaviour |
customClass | chingwe | ntchito | '' | Onjezani makalasi ku popover ikawonetsedwa. Dziwani kuti makalasi awa adzawonjezedwa kuwonjezera pa makalasi aliwonse omwe afotokozedwa mu template. Kuti muwonjezere makalasi angapo, alekanitseni ndi mipata: Mukhozanso kupereka ntchito yomwe iyenera kubweza chingwe chimodzi chokhala ndi mayina owonjezera amagulu. |
malire | chingwe | chinthu | 'scrollParent' | Kusefukira malire malire a popover. Imavomereza mfundo za 'viewport' , 'window' , 'scrollParent' , kapena HTMLElement reference (JavaScript yokha). Kuti mudziwe zambiri onani za Popper's preventOverflow docs . |
yeretsani | boolean | zoona | Yambitsani kapena kuletsa ukhondo. Ngati adamulowetsa 'template' , 'content' ndipo 'title' zosankha zidzayeretsedwa. Onani gawo la sanitizer muzolemba zathu za JavaScript . |
whiteList | chinthu | Mtengo wofikira | Chinthu chomwe chili ndi zovomerezeka ndi ma tag |
sanitizeFn | null | ntchito | null | Apa mutha kupereka ntchito yanu ya sanitize. Izi zitha kukhala zothandiza ngati mukufuna kugwiritsa ntchito laibulale yodzipatulira kuchita ukhondo. |
popperConfig | null | chinthu | null | Kuti musinthe kasinthidwe ka Popper ka Bootstrap, onani kasinthidwe ka Popper |
Mawonekedwe a data pamapopovers apawokha
Zosankha za popovers pawokha zitha kufotokozedwa mwanjira ina pogwiritsa ntchito mawonekedwe a data, monga tafotokozera pamwambapa.
Njira
Asynchronous njira ndi kusintha
Njira zonse za API ndizosasinthika ndipo zimayamba kusintha . Amabwerera kwa woyimbayo atangoyamba kusintha koma asanathe . Kuonjezera apo, kuyitana kwa njira pa gawo losintha kudzanyalanyazidwa .
$().popover(options)
Imayambitsa ma popover pazosonkhanitsira zinthu.
.popover('show')
Imawulula kuchuluka kwa zinthu. Imabwereranso kwa woyimba foniyo isanawonetsedwe (ie zisanachitike shown.bs.popover
). Izi zimaganiziridwa kuti ndi "zamanja" zoyambitsa popover. Ma Popovers omwe mutu wawo ndi zomwe zili muutali wa ziro sizimawonetsedwa.
$('#element').popover('show')
.popover('hide')
Imabisa kuchuluka kwa zinthu. Imabwereranso kwa woyimba foniyo isanabisike (ie zisanachitike hidden.bs.popover
). Izi zimaganiziridwa kuti ndi "zamanja" zoyambitsa popover.
$('#element').popover('hide')
.popover('toggle')
Imasintha kuphulika kwa chinthu. Imabwereranso kwa woyimba foniyo isanawonetsedwe kapena kubisidwa (ie zisanachitike shown.bs.popover
kapena hidden.bs.popover
chochitikacho). Izi zimaganiziridwa kuti ndi "zamanja" zoyambitsa popover.
$('#element').popover('toggle')
.popover('dispose')
Imabisa ndikuwononga kufalikira kwa chinthu. Ma Popovers omwe amagwiritsa ntchito kugawira ena (omwe amapangidwa pogwiritsa ntchito selector
mwayi ) sangawonongedwe paokha pazoyambitsa zoyambitsa.
$('#element').popover('dispose')
.popover('enable')
Zimapereka mwayi wowoneka bwino wa element. Popovers amayatsidwa mwachisawawa.
$('#element').popover('enable')
.popover('disable')
Imachotsa kuthekera kwa popover ya chinthu kuti iwonetsedwe. Popover imatha kuwonetsedwa ngati iyatsidwanso.
$('#element').popover('disable')
.popover('toggleEnabled')
Imasintha kuthekera kwa kufalikira kwa chinthu kuti chiwoneke kapena kubisika.
$('#element').popover('toggleEnabled')
.popover('update')
Imasinthiratu pomwe zinthu zachuluka.
$('#element').popover('update')
Zochitika
Mtundu wa Chochitika | Kufotokozera |
---|---|
onetsani.bs.popover | Chochitika ichi chimayaka nthawi yomweyo show njira yachitsanzo itayitanidwa. |
zowonetsedwa.bs.popover | Chochitikachi chimachotsedwa pamene popover yawonetsedwa kwa wogwiritsa ntchito (idzadikirira kuti kusintha kwa CSS kumalize). |
bisa.bs.popover | Chochitika ichi chimachotsedwa nthawi yomweyo pamene hide njira yachitsanzo yayitanidwa. |
zobisika.bs.popover | Chochitikachi chimachotsedwa pamene popover yatha kubisidwa kwa wogwiritsa ntchito (idikirira kuti kusintha kwa CSS kumalize). |
anaika.bs.popover | Chochitikachi chimachotsedwa pambuyo pa show.bs.popover chochitikacho pamene template ya popover yawonjezedwa ku DOM. |
$('#myPopover').on('hidden.bs.popover', function () {
// do something...
})